クラス
AmazonGenericError
ソース ソース
ファイル: src/Errors/AmazonGenericError.php
class AmazonGenericError extends GenericError
{
/**
* Amazon API raw result array
*
* @var array
*/
public $apiresult;
/**
* Creates a new error object with the given properties
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @param int|string $errorcode Any number|string representing an error code.
* @param string $errorname Name of the error.
* @param int $httpcode The HTTP code of the error
* @param callable|string $debugmsg A string message, or callable that constructs a message and takes
* any number of arguments. The debug message is for developers and
* should not be shown to end users.
* @param callable|string $message A string message, or callable that constructs a message and takes
* any number of arguments. This message should be a user facing
* message and should not contain debug information.
* @param callable|string $adminmsg A string message, or callable that constructs a message and takes
* any number of arguments. This message should be an admin facing
* message. Default: empty string
* @param mixed $logger Logger object
* @param array $apiresult A raw result object returned by an Amazon API call
* @return void
*/
public function __construct(
$errorcode,
$errorname,
$httpcode,
$debugmsg,
$message,
$adminmsg,
$logger,
$apiresult
) {
$this->errorcode = $errorcode;
$this->errorname = $errorname;
$this->httpcode = $httpcode;
$this->debugmsg = $debugmsg;
$this->message = $message;
$this->adminmsg = $adminmsg;
$this->logger = $logger;
$this->apiresult = $apiresult;
}
/**
* JSON serializes `AmazonGenericError` object for consumption by front-end
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return array
*/
public function jsonSerialize() {
return [
'errorcode' => $this->errorcode,
'errorname' => $this->errorname,
'debug' => is_callable($this->debugmsg) ? '' : $this->debugmsg,
'message' => is_callable($this->message) ? '' : $this->message,
'adminmsg' => is_callable($this->adminmsg) ? '' : $this->adminmsg,
'apiresult' => $this->apiresult,
];
}
}
- __construct — Creates a new error object with the given properties
- jsonSerialize — JSON serializes `AmazonGenericError` object for consumption by front-end