2021-10-18 18:24:38 +09:00
|
|
|
<?php
|
|
|
|
|
|
2021-10-21 09:55:32 +09:00
|
|
|
namespace gullevek\AmazonIncentives\Exceptions;
|
2021-10-18 18:24:38 +09:00
|
|
|
|
|
|
|
|
use RuntimeException;
|
2021-10-21 09:55:32 +09:00
|
|
|
use gullevek\AmazonIncentives\Debug\AmazonDebug;
|
2021-10-18 18:24:38 +09:00
|
|
|
|
|
|
|
|
class AmazonErrors extends RuntimeException
|
|
|
|
|
{
|
|
|
|
|
/**
|
2021-10-19 09:39:14 +09:00
|
|
|
* @param string $error_status agcodResponse->status from Amazon
|
|
|
|
|
* @param string $error_code errorCode from Amazon
|
|
|
|
|
* @param string $error_type errorType from Amazon
|
2021-10-18 18:24:38 +09:00
|
|
|
* @param string $message
|
|
|
|
|
* @param string $_error_code
|
|
|
|
|
* @return AmazonErrors
|
|
|
|
|
*/
|
|
|
|
|
public static function getError(
|
2021-10-19 09:39:14 +09:00
|
|
|
string $error_status,
|
2021-10-18 18:24:38 +09:00
|
|
|
string $error_code,
|
|
|
|
|
string $error_type,
|
|
|
|
|
string $message,
|
|
|
|
|
string $_error_code
|
|
|
|
|
): self {
|
|
|
|
|
// NOTE: if xdebug.show_exception_trace is set to 1 this will print ERRORS
|
|
|
|
|
return new static(
|
|
|
|
|
json_encode([
|
2021-10-19 09:39:14 +09:00
|
|
|
'status' => $error_status,
|
2021-10-18 18:24:38 +09:00
|
|
|
'code' => $error_code,
|
|
|
|
|
'type' => $error_type,
|
|
|
|
|
'message' => $message,
|
|
|
|
|
// atach log data if exists
|
2021-10-21 09:55:32 +09:00
|
|
|
'log_id' => AmazonDebug::getId(),
|
|
|
|
|
'log' => AmazonDebug::getLog(),
|
2021-10-18 18:24:38 +09:00
|
|
|
]),
|
|
|
|
|
$_error_code
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// __END__
|