Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9f7631b

Browse filesBrowse files
authored
Clarify which is the top level exception for http client if you want to catch everything
1 parent db09e71 commit 9f7631b
Copy full SHA for 9f7631b

File tree

Expand file treeCollapse file tree

1 file changed

+14
-13
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-13
lines changed

‎http_client.rst

Copy file name to clipboardExpand all lines: http_client.rst
+14-13Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -924,10 +924,22 @@ In case the response was canceled using ``$response->cancel()``,
924924
Handling Exceptions
925925
~~~~~~~~~~~~~~~~~~~
926926

927+
There are three types of exceptions, all of which implement the
928+
:class:`Symfony\\Contracts\\HttpClient\\Exception\\ExceptionInterface`:
929+
930+
* Exceptions implementing the :class:`Symfony\\Contracts\\HttpClient\\Exception\\HttpExceptionInterface`
931+
are thrown when your code does not handle the status codes in the 300-599 range.
932+
933+
* Exceptions implementing the :class:`Symfony\\Contracts\\HttpClient\\Exception\\TransportExceptionInterface`
934+
are thrown when a lower level issue occurs.
935+
936+
* Exceptions implementing the :class:`Symfony\\Contracts\\HttpClient\\Exception\\DecodingExceptionInterface`
937+
are thrown when a content-type cannot be decoded to the expected representation.
938+
927939
When the HTTP status code of the response is in the 300-599 range (i.e. 3xx,
928940
4xx or 5xx) your code is expected to handle it. If you don't do that, the
929-
``getHeaders()``, ``getContent()`` and ``toArray()`` methods throw an appropriate exception, all of
930-
which implement the :class:`Symfony\\Contracts\\HttpClient\\Exception\\HttpExceptionInterface`::
941+
``getHeaders()``, ``getContent()`` and ``toArray()`` methods throw an appropriate exception, which will
942+
implement the :class:`Symfony\\Contracts\\HttpClient\\Exception\\HttpExceptionInterface`::
931943

932944
// the response of this request will be a 403 HTTP error
933945
$response = $client->request('GET', 'https://httpbin.org/status/403');
@@ -968,17 +980,6 @@ errors, exceptions will notify you when needed. On the other hand, if you write
968980
the error-handling code, you will opt-out from these fallback mechanisms as the
969981
destructor won't have anything remaining to do.
970982

971-
There are three types of exceptions:
972-
973-
* Exceptions implementing the :class:`Symfony\\Contracts\\HttpClient\\Exception\\HttpExceptionInterface`
974-
are thrown when your code does not handle the status codes in the 300-599 range.
975-
976-
* Exceptions implementing the :class:`Symfony\\Contracts\\HttpClient\\Exception\\TransportExceptionInterface`
977-
are thrown when a lower level issue occurs.
978-
979-
* Exceptions implementing the :class:`Symfony\\Contracts\\HttpClient\\Exception\\DecodingExceptionInterface`
980-
are thrown when a content-type cannot be decoded to the expected representation.
981-
982983
Concurrent Requests
983984
-------------------
984985

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.