firstred / postnl-api-php

PostNL API PHP bindings
https://postnl-php.readthedocs.io
MIT License
26 stars 37 forks source link

fix: make HttpClientException::response nullable #85

Closed annuh closed 9 months ago

annuh commented 10 months ago

This makes the property HttpClientException->response nullable, and avoids a PHP error, because the response is not always known or given. By making response nullable we can catch the real exception.

Here is an example trace:

Cannot assign null to property Firstred\\PostNL\\Exception\\HttpClientException::$response of type Psr\\Http\\Message\\ResponseInterface

#0 /var/www/html/vendor/firstred/postnl-api-php/src/HttpClient/SymfonyHttpClient.php(193): Firstred\\PostNL\\Exception\\HttpClientException->__construct('Response factor...', 0, Object(Firstred\\PostNL\\Exception\\NotSupportedException))
#1 /var/www/html/vendor/firstred/postnl-api-php/src/Service/LabellingService.php(120): Firstred\\PostNL\\HttpClient\\SymfonyHttpClient->doRequest(Object(GuzzleHttp\\Psr7\\Request))
#2 /var/www/html/vendor/firstred/postnl-api-php/src/PostNL.php(1455): Firstred\\PostNL\\Service\\LabellingService->generateLabel(Object(Firstred\\PostNL\\Entity\\Request\\GenerateLabel), false)
firstred commented 9 months ago

Looks good to me. Thanks for the pull request!