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 Firstred\PostNL\Exception\PostNLException s and Psr\Cache\InvalidArgumentException s.

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

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