Sendcloud error handling

This commit is contained in:
Andreas Palm
2023-01-29 23:38:27 +01:00
parent 3fe2c7a5d9
commit 575ab86157
4 changed files with 7 additions and 7 deletions
@@ -8,11 +8,11 @@ class SendcloudApiException extends Exception
{
public static function fromResponse(array $response) : SendcloudApiException {
if (!isset($response['body']) || !is_object($response['body']))
return new SendcloudApiException();
return new SendcloudApiException(print_r($response,true));
return new SendcloudApiException(
$response['body']->error->message ?? '',
$response['body']->error->code ?? 0
print_r($response['body'],true),
$response['code']
);
}
}