Skip to content

Latest commit

 

History

History
83 lines (60 loc) · 3.23 KB

exceptionhandling.rst

File metadata and controls

83 lines (60 loc) · 3.23 KB

Exception handling

The following tree view describes how the exceptions used in this library depend on each other.

. \Exception
├── Firstred\PostNL\Exception\PostNLException
│   ├── Firstred\PostNL\Exception\ApiException
│   │   ├── Firstred\PostNL\Exception\ApiConnectionException
│   │   ├── Firstred\PostNL\Exception\CifDownException
│   │   ├── Firstred\PostNL\Exception\CifException
│   │   ├── Firstred\PostNL\Exception\NotFoundException
│   │   ├── Firstred\PostNL\Exception\ResponseException
│   │   └── Firstred\PostNL\Exception\ShipmentNotFoundException
│   ├── Firstred\PostNL\Exception\HttpClientException
│   └── Firstred\PostNL\Exception\InvalidArgumentException
│       ├── Firstred\PostNL\Exception\InvalidBarcodeException
│       ├── Firstred\PostNL\Exception\InvalidConfigurationException
│       ├── Firstred\PostNL\Exception\InvalidMethodException
│       ├── Firstred\PostNL\Exception\NotImplementedException
│       └── Firstred\PostNL\Exception\NotSupportedException
└── Psr\Cache\InvalidArgumentException

This library throws exceptions for errors that occur during a request.

If you want to catch all exceptions thrown by this library be sure to catch both :php:class:`Firstred\\PostNL\\Exception\\PostNLException` s and :php:class:`Psr\\Cache\\InvalidArgumentException` s.

.. tabs::

    .. tab:: PHP 7.0 or lower

        .. code-block:: php

            use Firstred\PostNL\Exception\PostNLException;
            use Psr\Cache\InvalidArgumentException as PsrCacheInvalidArgumentException;

            try {
                $postnl->getTimeframes(...);
            } catch (PostNLException $e) {
                // ...
            } catch (PsrCacheInvalidArgumentException $e) {
                // ...
            }

    .. tab:: PHP 7.1 or higher

        .. code-block:: php

            use Firstred\PostNL\Exception\PostNLException;
            use Psr\Cache\InvalidArgumentException as PsrCacheInvalidArgumentException;

            try {
                $postnl->getTimeframes(...);
            } catch (PostNLException | PsrCacheInvalidArgumentException $e) {
                // ...
            }