Skip to content

Commit 56d83c7

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Clarified the three main types of exceptions thrown in HttpClient
2 parents 0343ec7 + 10f5cf0 commit 56d83c7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

components/http_client.rst

+13-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ Handling Exceptions
420420

421421
When the HTTP status code of the response is in the 300-599 range (i.e. 3xx,
422422
4xx or 5xx) your code is expected to handle it. If you don't do that, the
423-
``getHeaders()`` and ``getContent()`` methods throw an appropriate exception::
423+
``getHeaders()`` and ``getContent()`` methods throw an appropriate exception, all of
424+
which implement the :class:`Symfony\\Contracts\\HttpClient\\Exception\\HttpExceptionInterface`::
424425

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

465+
There are three types of exceptions:
466+
467+
* Exceptions implementing the :class:`Symfony\\Contracts\\HttpClient\\Exception\\HttpExceptionInterface`
468+
are thrown when your code does not handle the status codes in the 300-599 range.
469+
470+
* Exceptions implementing the :class:`Symfony\\Contracts\\HttpClient\\Exception\\TransportExceptionInterface`
471+
are thrown when a lower level issue occurs.
472+
473+
* Exceptions implementing the :class:`Symfony\\Contracts\\HttpClient\\Exception\\DecodingExceptionInterface`
474+
are thrown when a content-type cannot be decoded to the expected representation.
475+
464476
Concurrent Requests
465477
-------------------
466478

0 commit comments

Comments
 (0)