Файл: monst/Xsolla/Xsolla/SDK/Exception/API/XsollaAPIException.php
Строк: 40
<?php
namespace XsollaSDKExceptionAPI;
use GuzzleHttpExceptionBadResponseException;
use XsollaSDKExceptionXsollaException;
class XsollaAPIException extends XsollaException
{
protected static $exceptions = array(
422 => 'XsollaSDKExceptionAPIUnprocessableEntityException',
403 => 'XsollaSDKExceptionAPIAccessDeniedException',
);
protected static $messageTemplate =
<<<'EOF'
Xsolla API Error Response:
Previous Exception:
===================
%s
Request:
===================
%s
Response:
===================
%s
EOF;
/**
* @param BadResponseException $previous
* @return XsollaAPIException
*/
public static function fromBadResponse(BadResponseException $previous)
{
$statusCode = $previous->getResponse()->getStatusCode();
$message = sprintf(
static::$messageTemplate,
$previous->getMessage(),
$previous->getRequest(),
$previous->getResponse()
);
if (array_key_exists($statusCode, static::$exceptions)) {
return new static::$exceptions[$statusCode]($message, 0, $previous);
}
return new self($message, 0, $previous);
}
}