OpenXE/classes/Carrier/SendCloud/SendcloudApiException.php

24 lines
539 B
PHP
Raw Normal View History

2022-11-02 22:37:04 +01:00
<?php
2023-02-28 13:36:25 +01:00
/*
* SPDX-FileCopyrightText: 2022 Andreas Palm
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
2022-11-02 22:37:04 +01:00
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']))
2023-01-29 21:11:12 +01:00
return new SendcloudApiException(print_r($response,true));
2022-11-02 22:37:04 +01:00
return new SendcloudApiException(
2023-01-29 21:11:12 +01:00
print_r($response['body'],true),
$response['code']
2022-11-02 22:37:04 +01:00
);
}
}