You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: framework-docs/modules/ROOT/pages/integration/rest-clients.adoc
+40-5Lines changed: 40 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1079,10 +1079,30 @@ underlying HTTP client, which operates at a lower level and provides more contro
1079
1079
1080
1080
[[rest-http-interface-exceptions]]
1081
1081
=== Exception Handling
1082
+
In order to provide a custom way of handling errors, you can register response
1083
+
status handlers on the underlying HTTP clients.
1082
1084
1083
-
By default, `WebClient` raises `WebClientResponseException` for 4xx and 5xx HTTP status
1084
-
codes. To customize this, you can register a response status handler that applies to all
1085
-
responses performed through the client:
1085
+
For `RestClient`:
1086
+
1087
+
By default, `RestClient` raises `RestClientException` for 4xx and 5xx HTTP status codes. To customize this, you can register a response status handler that applies to all responses performed through the client:
For more details and options, such as suppressing error status codes, see the Javadoc of `defaultStatusHandler` in `RestClient.Builder`.
1102
+
1103
+
For `WebClient`:
1104
+
1105
+
By default, `WebClient` raises `WebClientResponseException` for 4xx and 5xx HTTP status codes. To customize this, you can register a response status handler that applies to all responses performed through the client:
1086
1106
1087
1107
[source,java,indent=0,subs="verbatim,quotes"]
1088
1108
----
@@ -1095,5 +1115,20 @@ responses performed through the client:
1095
1115
.builder(clientAdapter).build();
1096
1116
----
1097
1117
1098
-
For more details and options, such as suppressing error status codes, see the Javadoc of
1099
-
`defaultStatusHandler` in `WebClient.Builder`.
1118
+
For more details and options, such as suppressing error status codes, see the Javadoc of `defaultStatusHandler` in `WebClient.Builder`.
1119
+
1120
+
For `RestTemplate`:
1121
+
1122
+
By default, `RestTemplate` raises `RestClientException` for 4xx and 5xx HTTP status codes. To customize this, you can register an error handler that applies to all responses performed through the client:
0 commit comments