← All changes
|
includes/sdk/s3/Aws/Api/ErrorParser/RestJsonErrorParser.php
+4
-9
1.2.7
→
1.4.2
View file →
| @@ -13,31 +13,26 @@ | ||
| 13 | 13 | class RestJsonErrorParser extends AbstractErrorParser |
| 14 | 14 | { |
| 15 | 15 | use JsonParserTrait; |
| 16 | 16 | private $parser; |
| 17 | - public function __construct(Service $api = null, JsonParser $parser = null) | |
| 17 | + public function __construct(?Service $api = null, ?JsonParser $parser = null) | |
| 18 | 18 | { |
| 19 | 19 | parent::__construct($api); |
| 20 | 20 | $this->parser = $parser ?: new JsonParser(); |
| 21 | 21 | } |
| 22 | - public function __invoke(ResponseInterface $response, CommandInterface $command = null) | |
| 22 | + public function __invoke(ResponseInterface $response, ?CommandInterface $command = null) | |
| 23 | 23 | { |
| 24 | 24 | $data = $this->genericHandler($response); |
| 25 | 25 | // Merge in error data from the JSON body |
| 26 | 26 | if ($json = $data['parsed']) { |
| 27 | - $data = \array_replace($data, $json); | |
| 27 | + $data = \array_replace($json, $data); | |
| 28 | 28 | } |
| 29 | 29 | // Correct error type from services like Amazon Glacier |
| 30 | 30 | if (!empty($data['type'])) { |
| 31 | 31 | $data['type'] = \strtolower($data['type']); |
| 32 | 32 | } |
| 33 | - // Retrieve the error code from services like Amazon Elastic Transcoder | |
| 34 | - if ($code = $response->getHeaderLine('x-amzn-errortype')) { | |
| 35 | - $colon = \strpos($code, ':'); | |
| 36 | - $data['code'] = $colon ? \substr($code, 0, $colon) : $code; | |
| 37 | - } | |
| 38 | 33 | // Retrieve error message directly |
| 39 | - $data['message'] = isset($data['parsed']['message']) ? $data['parsed']['message'] : (isset($data['parsed']['Message']) ? $data['parsed']['Message'] : null); | |
| 34 | + $data['message'] = $data['parsed']['message'] ?? $data['parsed']['Message'] ?? null; | |
| 40 | 35 | $this->populateShape($data, $response, $command); |
| 41 | 36 | return $data; |
| 42 | 37 | } |
| 43 | 38 | } |