@@ -1020,10 +1020,22 @@ In case the response was canceled using ``$response->cancel()``,
1020
1020
Handling Exceptions
1021
1021
~~~~~~~~~~~~~~~~~~~
1022
1022
1023
+ There are three types of exceptions, all of which implement the
1024
+ :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ ExceptionInterface `:
1025
+
1026
+ * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ HttpExceptionInterface `
1027
+ are thrown when your code does not handle the status codes in the 300-599 range.
1028
+
1029
+ * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ TransportExceptionInterface `
1030
+ are thrown when a lower level issue occurs.
1031
+
1032
+ * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ DecodingExceptionInterface `
1033
+ are thrown when a content-type cannot be decoded to the expected representation.
1034
+
1023
1035
When the HTTP status code of the response is in the 300-599 range (i.e. 3xx,
1024
1036
4xx or 5xx) your code is expected to handle it. If you don't do that, the
1025
- ``getHeaders() ``, ``getContent() `` and ``toArray() `` methods throw an appropriate exception, all of
1026
- which implement the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ HttpExceptionInterface `::
1037
+ ``getHeaders() ``, ``getContent() `` and ``toArray() `` methods throw an appropriate exception, which will
1038
+ implement the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ HttpExceptionInterface `::
1027
1039
1028
1040
// the response of this request will be a 403 HTTP error
1029
1041
$response = $client->request('GET', 'https://httpbin.org/status/403');
@@ -1061,19 +1073,9 @@ responses in an array::
1061
1073
This behavior provided at destruction-time is part of the fail-safe design of the
1062
1074
component. No errors will be unnoticed: if you don't write the code to handle
1063
1075
errors, exceptions will notify you when needed. On the other hand, if you write
1064
- the error-handling code, you will opt-out from these fallback mechanisms as the
1065
- destructor won't have anything remaining to do.
1066
-
1067
- There are three types of exceptions:
1068
-
1069
- * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ HttpExceptionInterface `
1070
- are thrown when your code does not handle the status codes in the 300-599 range.
1071
-
1072
- * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ TransportExceptionInterface `
1073
- are thrown when a lower level issue occurs.
1074
-
1075
- * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ DecodingExceptionInterface `
1076
- are thrown when a content-type cannot be decoded to the expected representation.
1076
+ the error-handling code (by calling ``$response->getStatusCode() ``), you will
1077
+ opt-out from these fallback mechanisms as the destructor won't have anything
1078
+ remaining to do.
1077
1079
1078
1080
Concurrent Requests
1079
1081
-------------------
0 commit comments