関数
GenericErrorStore::getAmzErrorResponse( array $result, WCEXAAP\Aivec\ResponseHandler\ErrorStore|null $contextapi = null )
AmazonGenericError object created from an Amazon API error説明 説明
If $contextapi is provided and an error response is defined for $contextapi, it is returned. If $contextapi is not provided, a generic error lookup will take place.
- $result
(配列) (必須)
- $contextapi
(WCEXAAP\Aivec\ResponseHandler\ErrorStore) (任意) object that extends
ErrorStoreand provides errors specific to the API
ファイル: src/Errors/GenericErrorStore.php
public function getAmzErrorResponse(array $result, ErrorStore $contextapi = null) {
$status = (int)$result['status'];
$body = json_decode($result['response'], true);
$reasonCode = $body['reasonCode'];
$debugMessage = $body['message'];
$error = null;
if ($status >= 400) {
if ($contextapi !== null) {
$apierrmap = $contextapi->getErrorCodeMap();
if (isset($apierrmap[$reasonCode])) {
$error = $contextapi->getErrorResponse($reasonCode, [$debugMessage]);
return new AmazonGenericError(
$error->errorcode,
$error->errorname,
$error->httpcode,
$error->debugmsg,
$error->message,
$error->adminmsg,
$error->logger,
$result
);
}
}
$error = $this->getErrorResponse($reasonCode, [$debugMessage]);
}
if ($error !== null) {
return new AmazonGenericError(
$error->errorcode,
$error->errorname,
$error->httpcode,
$error->debugmsg,
$error->message,
$error->adminmsg,
$error->logger,
$result
);
}
$defaultErrors = $this->getErrorCodeMap();
$unknownError = $defaultErrors[ErrorStore::UNKNOWN_ERROR];
return new AmazonGenericError(
$unknownError->errorcode,
$unknownError->errorname,
$unknownError->httpcode,
$unknownError->debugmsg,
$unknownError->message,
$unknownError->adminmsg,
$unknownError->logger,
$result
);
}