@@ -436,7 +436,8 @@ Handling Exceptions
436
436
437
437
When the HTTP status code of the response is in the 300-599 range (i.e. 3xx,
438
438
4xx or 5xx) your code is expected to handle it. If you don't do that, the
439
- ``getHeaders() `` and ``getContent() `` methods throw an appropriate exception::
439
+ ``getHeaders() `` and ``getContent() `` methods throw an appropriate exception, all of
440
+ which implement the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ HttpExceptionInterface `::
440
441
441
442
// the response of this request will be a 403 HTTP error
442
443
$response = $client->request('GET', 'https://httpbin.org/status/403');
@@ -476,6 +477,29 @@ component. No errors will be unnoticed: if you don't write the code to handle
476
477
errors, exceptions will notify you when needed. On the other hand, if you write
477
478
the error-handling code, you will opt-out from these fallback mechanisms as the
478
479
destructor won't have anything remaining to do.
480
+ =======
481
+
482
+ Thus, there are two types of exceptions:
483
+
484
+ * Exceptions implementing the ``HttpExceptionInterface `` are thrown when your code
485
+ does not handle the status codes in the 300-599 range.
486
+ When streaming responses, these exceptions do not interrupt the stream as you might
487
+ still want to read the content of these responses.
488
+ That being said, be aware that they are thrown on every single chunk.
489
+
490
+ * ``TransportExceptionInterface `` exceptions signal a lower level issue.
491
+ Thus, when streaming responses, the exception will only be thrown once.
492
+
493
+ There are three types of exceptions:
494
+
495
+ * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ HttpExceptionInterface ` are thrown when
496
+ your code does not handle the status codes in the 300-599 range.
497
+
498
+ * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ TransportExceptionInterface ` are thrown
499
+ when a lower level issue occurs.
500
+
501
+ * Exceptions implementing the :class: `Symfony\\ Contracts\\ HttpClient\\ Exception\\ DecodingExceptionInterface ` are thrown
502
+ when a content-type cannot be decoded to the expected representation.
479
503
480
504
Concurrent Requests
481
505
-------------------
0 commit comments