PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / Api / ErrorParser / JsonRpcErrorParser.php
transferito / vendor / aws / aws-sdk-php / src / Api / ErrorParser Last commit date
AbstractErrorParser.php 11 months ago JsonParserTrait.php 11 months ago JsonRpcErrorParser.php 11 months ago RestJsonErrorParser.php 11 months ago XmlErrorParser.php 11 months ago
JsonRpcErrorParser.php
50 lines
1 <?php
2 namespace Aws\Api\ErrorParser;
3
4 use Aws\Api\Parser\JsonParser;
5 use Aws\Api\Service;
6 use Aws\CommandInterface;
7 use Psr\Http\Message\ResponseInterface;
8
9 /**
10 * Parsers JSON-RPC errors.
11 */
12 class JsonRpcErrorParser extends AbstractErrorParser
13 {
14 use JsonParserTrait;
15
16 private $parser;
17
18 public function __construct(Service $api = null, JsonParser $parser = null)
19 {
20 parent::__construct($api);
21 $this->parser = $parser ?: new JsonParser();
22 }
23
24 public function __invoke(
25 ResponseInterface $response,
26 CommandInterface $command = null
27 ) {
28 $data = $this->genericHandler($response);
29
30 // Make the casing consistent across services.
31 if ($data['parsed']) {
32 $data['parsed'] = array_change_key_case($data['parsed']);
33 }
34
35 if (isset($data['parsed']['__type'])) {
36 if (!isset($data['code'])) {
37 $parts = explode('#', $data['parsed']['__type']);
38 $data['code'] = isset($parts[1]) ? $parts[1] : $parts[0];
39 }
40 $data['message'] = isset($data['parsed']['message'])
41 ? $data['parsed']['message']
42 : null;
43 }
44
45 $this->populateShape($data, $response, $command);
46
47 return $data;
48 }
49 }
50