@@ -998,10 +998,22 @@ In case the response was canceled using ``$response->cancel()``,
998
998
Handling Exceptions
999
999
~~~~~~~~~~~~~~~~~~~
1000
1000
1001
+ There are three types of exceptions, all of which implement the
1002
+ :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ ExceptionInterface `:
1003
+
1004
+ * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ HttpExceptionInterface `
1005
+ are thrown when your code does not handle the status codes in the 300-599 range.
1006
+
1007
+ * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ TransportExceptionInterface `
1008
+ are thrown when a lower level issue occurs.
1009
+
1010
+ * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ DecodingExceptionInterface `
1011
+ are thrown when a content-type cannot be decoded to the expected representation.
1012
+
1001
1013
When the HTTP status code of the response is in the 300-599 range (i.e. 3xx,
1002
1014
4xx or 5xx) your code is expected to handle it. If you don't do that, the
1003
- ``getHeaders() ``, ``getContent() `` and ``toArray() `` methods throw an appropriate exception, all of
1004
- which implement the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ HttpExceptionInterface `::
1015
+ ``getHeaders() ``, ``getContent() `` and ``toArray() `` methods throw an appropriate exception, which will
1016
+ implement the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ HttpExceptionInterface `::
1005
1017
1006
1018
// the response of this request will be a 403 HTTP error
1007
1019
$response = $client->request('GET', 'https://httpbin.org/status/403');
@@ -1039,19 +1051,9 @@ responses in an array::
1039
1051
This behavior provided at destruction-time is part of the fail-safe design of the
1040
1052
component. No errors will be unnoticed: if you don't write the code to handle
1041
1053
errors, exceptions will notify you when needed. On the other hand, if you write
1042
- the error-handling code, you will opt-out from these fallback mechanisms as the
1043
- destructor won't have anything remaining to do.
1044
-
1045
- There are three types of exceptions:
1046
-
1047
- * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ HttpExceptionInterface `
1048
- are thrown when your code does not handle the status codes in the 300-599 range.
1049
-
1050
- * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ TransportExceptionInterface `
1051
- are thrown when a lower level issue occurs.
1052
-
1053
- * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ DecodingExceptionInterface `
1054
- are thrown when a content-type cannot be decoded to the expected representation.
1054
+ the error-handling code (by calling ``$response->getStatusCode() ``), you will
1055
+ opt-out from these fallback mechanisms as the destructor won't have anything
1056
+ remaining to do.
1055
1057
1056
1058
Concurrent Requests
1057
1059
-------------------
0 commit comments