← All changes
|
includes/sdk/s3/Aws/Api/ErrorParser/JsonRpcErrorParser.php
+7
-5
1.0.1
→
1.4.2
View file →
| @@ -12,14 +12,14 @@ | ||
| 12 | 12 | class JsonRpcErrorParser extends AbstractErrorParser |
| 13 | 13 | { |
| 14 | 14 | use JsonParserTrait; |
| 15 | 15 | private $parser; |
| 16 | - public function __construct(Service $api = null, JsonParser $parser = null) | |
| 16 | + public function __construct(?Service $api = null, ?JsonParser $parser = null) | |
| 17 | 17 | { |
| 18 | 18 | parent::__construct($api); |
| 19 | 19 | $this->parser = $parser ?: new JsonParser(); |
| 20 | 20 | } |
| 21 | - public function __invoke(ResponseInterface $response, CommandInterface $command = null) | |
| 21 | + public function __invoke(ResponseInterface $response, ?CommandInterface $command = null) | |
| 22 | 22 | { |
| 23 | 23 | $data = $this->genericHandler($response); |
| 24 | 24 | // Make the casing consistent across services. |
| 25 | 25 | if ($data['parsed']) { |
| @@ -25,11 +25,13 @@ | ||
| 25 | 25 | if ($data['parsed']) { |
| 26 | 26 | $data['parsed'] = \array_change_key_case($data['parsed']); |
| 27 | 27 | } |
| 28 | 28 | if (isset($data['parsed']['__type'])) { |
| 29 | - $parts = \explode('#', $data['parsed']['__type']); | |
| 30 | - $data['code'] = isset($parts[1]) ? $parts[1] : $parts[0]; | |
| 31 | - $data['message'] = isset($data['parsed']['message']) ? $data['parsed']['message'] : null; | |
| 29 | + if (!isset($data['code'])) { | |
| 30 | + $parts = \explode('#', $data['parsed']['__type']); | |
| 31 | + $data['code'] = isset($parts[1]) ? $parts[1] : $parts[0]; | |
| 32 | + } | |
| 33 | + $data['message'] = $data['parsed']['message'] ?? null; | |
| 32 | 34 | } |
| 33 | 35 | $this->populateShape($data, $response, $command); |
| 34 | 36 | return $data; |
| 35 | 37 | } |