OpenXE/classes/Carrier/SendCloud/SendcloudApiException.php

18 lines
444 B
PHP
Raw Normal View History

2022-11-02 22:37:04 +01:00
<?php
namespace Xentral\Carrier\SendCloud;
use Exception;
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(
$response['body']->error->message ?? '',
$response['body']->error->code ?? 0
);
}
}