Move decode error method, minor text update for error strings
the method "decodeExceptionMessage" has moved from AmazonIncentives\AmazonIncentives to AmazonIncentives\Exceptions\AmazonErrors The old method is currently tagged deprecated internal via @deprecated PHPdoc entry
This commit is contained in:
@@ -137,22 +137,12 @@ final class AmazonIncentives
|
||||
*
|
||||
* @param string $message Exception message json string
|
||||
* @return array<mixed> Decoded with code, type, message fields
|
||||
*
|
||||
* @deprecated use \gullevek\AmazonIncentives\Exceptions\AmazonErrors::decodeExceptionMessage()
|
||||
*/
|
||||
public static function decodeExceptionMessage(string $message): array
|
||||
{
|
||||
$message_ar = json_decode($message, true);
|
||||
// if we have an error, build empty block and only fill message
|
||||
if (json_last_error()) {
|
||||
$message_ar = [
|
||||
'status' => '',
|
||||
'code' => '',
|
||||
'type' => '',
|
||||
'message' => $message,
|
||||
'log_id' => '',
|
||||
'log' => []
|
||||
];
|
||||
}
|
||||
return $message_ar;
|
||||
return AmazonErrors::decodeExceptionMessage($message);
|
||||
}
|
||||
|
||||
// *********************************************************************
|
||||
|
||||
@@ -91,13 +91,13 @@ class Client implements ClientInterface
|
||||
case CURLE_COULDNT_CONNECT:
|
||||
case CURLE_COULDNT_RESOLVE_HOST:
|
||||
case CURLE_OPERATION_TIMEOUTED:
|
||||
$message = 'Could not connect to AWS (' . $url . '). Please check your '
|
||||
$message = 'Could not connect to AWS (' . $url . '). Please check your '
|
||||
. 'internet connection and try again. [' . $message . ']';
|
||||
break;
|
||||
case CURLE_SSL_PEER_CERTIFICATE:
|
||||
$message = 'Could not verify AWS SSL certificate. Please make sure '
|
||||
. 'that your network is not intercepting certificates. '
|
||||
. '(Try going to ' . $url . 'in your browser.) '
|
||||
$message = 'Could not verify AWS SSL certificate. Please make sure '
|
||||
. 'that your network is not intercepting certificates. '
|
||||
. '(Try going to ' . $url . 'in your browser.) '
|
||||
. '[' . $message . ']';
|
||||
break;
|
||||
case 0:
|
||||
|
||||
@@ -39,6 +39,31 @@ final class AmazonErrors extends RuntimeException
|
||||
$_error_code
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the Exception message body
|
||||
* Returns an array with code (Amazon error codes), type (Amazon error info)
|
||||
* message (Amazon returned error message string)
|
||||
*
|
||||
* @param string $message Exception message json string
|
||||
* @return array<mixed> Decoded with code, type, message fields
|
||||
*/
|
||||
public static function decodeExceptionMessage(string $message): array
|
||||
{
|
||||
$message_ar = json_decode($message, true);
|
||||
// if we have an error, build empty block and only fill message
|
||||
if (json_last_error()) {
|
||||
$message_ar = [
|
||||
'status' => '',
|
||||
'code' => '',
|
||||
'type' => '',
|
||||
'message' => $message,
|
||||
'log_id' => '',
|
||||
'log' => []
|
||||
];
|
||||
}
|
||||
return $message_ar;
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
|
||||
Reference in New Issue
Block a user