From 0c8af4992cb0f7589dcafaad65ada12753c64594 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 23 Nov 2022 21:14:33 +0300 Subject: initial --- .../src/Api/ErrorParser/JsonParserTrait.php | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 vendor/aws/aws-sdk-php/src/Api/ErrorParser/JsonParserTrait.php (limited to 'vendor/aws/aws-sdk-php/src/Api/ErrorParser/JsonParserTrait.php') diff --git a/vendor/aws/aws-sdk-php/src/Api/ErrorParser/JsonParserTrait.php b/vendor/aws/aws-sdk-php/src/Api/ErrorParser/JsonParserTrait.php new file mode 100644 index 0000000..92b447c --- /dev/null +++ b/vendor/aws/aws-sdk-php/src/Api/ErrorParser/JsonParserTrait.php @@ -0,0 +1,52 @@ +getStatusCode(); + if ($this->api + && $this->api->getMetadata('awsQueryCompatible') + && $response->getHeaderLine('x-amzn-query-error') + ) { + $queryError = $response->getHeaderLine('x-amzn-query-error'); + $parts = explode(';', $queryError); + if (isset($parts) && count($parts) == 2 && $parts[0] && $parts[1]) { + $error_code = $parts[0]; + $error_type = $parts[1]; + } + } + if (!isset($error_type)) { + $error_type = $code[0] == '4' ? 'client' : 'server'; + } + + return [ + 'request_id' => (string) $response->getHeaderLine('x-amzn-requestid'), + 'code' => isset($error_code) ? $error_code : null, + 'message' => null, + 'type' => $error_type, + 'parsed' => $this->parseJson($response->getBody(), $response) + ]; + } + + protected function payload( + ResponseInterface $response, + StructureShape $member + ) { + $jsonBody = $this->parseJson($response->getBody(), $response); + + if ($jsonBody) { + return $this->parser->parse($member, $jsonBody); + } + } +} -- cgit v1.2.3