|
3 | 3 | ================== |
4 | 4 | Exception handling |
5 | 5 | ================== |
| 6 | + |
| 7 | +**Tree View** |
| 8 | + |
| 9 | +The following tree view describes how the exceptions used in this library depend |
| 10 | +on each other. |
| 11 | + |
| 12 | +.. code-block:: none |
| 13 | +
|
| 14 | + . \Exception |
| 15 | + ├── Firstred\PostNL\Exception\PostNLException |
| 16 | + │ ├── Firstred\PostNL\Exception\ApiException |
| 17 | + │ │ ├── Firstred\PostNL\Exception\ApiConnectionException |
| 18 | + │ │ ├── Firstred\PostNL\Exception\CifDownException |
| 19 | + │ │ ├── Firstred\PostNL\Exception\CifException |
| 20 | + │ │ ├── Firstred\PostNL\Exception\NotFoundException |
| 21 | + │ │ ├── Firstred\PostNL\Exception\ResponseException |
| 22 | + │ │ └── Firstred\PostNL\Exception\ShipmentNotFoundException |
| 23 | + │ ├── Firstred\PostNL\Exception\HttpClientException |
| 24 | + │ └── Firstred\PostNL\Exception\InvalidArgumentException |
| 25 | + │ ├── Firstred\PostNL\Exception\InvalidBarcodeException |
| 26 | + │ ├── Firstred\PostNL\Exception\InvalidConfigurationException |
| 27 | + │ ├── Firstred\PostNL\Exception\InvalidMethodException |
| 28 | + │ ├── Firstred\PostNL\Exception\NotImplementedException |
| 29 | + │ └── Firstred\PostNL\Exception\NotSupportedException |
| 30 | + └── Psr\Cache\InvalidArgumentException |
| 31 | +
|
| 32 | +Guzzle throws exceptions for errors that occur during a transfer. |
| 33 | + |
| 34 | +- In the event of a networking error (connection timeout, DNS errors, etc.), |
| 35 | + a ``GuzzleHttp\Exception\RequestException`` is thrown. This exception |
| 36 | + extends from ``GuzzleHttp\Exception\TransferException``. Catching this |
| 37 | + exception will catch any exception that can be thrown while transferring |
| 38 | + requests. |
| 39 | + |
| 40 | + .. code-block:: php |
| 41 | +
|
| 42 | + use GuzzleHttp\Psr7; |
| 43 | + use GuzzleHttp\Exception\RequestException; |
| 44 | +
|
| 45 | + try { |
| 46 | + $client->request('GET', 'https://github.com/_abc_123_404'); |
| 47 | + } catch (RequestException $e) { |
| 48 | + echo Psr7\Message::toString($e->getRequest()); |
| 49 | + if ($e->hasResponse()) { |
| 50 | + echo Psr7\Message::toString($e->getResponse()); |
| 51 | + } |
| 52 | + } |
| 53 | +
|
| 54 | +- A ``GuzzleHttp\Exception\ConnectException`` exception is thrown in the |
| 55 | + event of a networking error. This exception extends from |
| 56 | + ``GuzzleHttp\Exception\TransferException``. |
0 commit comments