v2: Updates

* Simplifies & beautifies everything
* Introduces a new Class system.
* Errors are defaulted to AWS's handler.
* New function names & more efficient handling.
* Should fix a majority of the errors.

Please read the README for more!
This commit is contained in:
Devang Srivastava 2020-09-28 15:32:51 +05:30
commit e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions

View file

@ -2,6 +2,7 @@
namespace Aws\Api\Parser;
use Aws\Api\Parser\Exception\ParserException;
use Psr\Http\Message\ResponseInterface;
trait PayloadParserTrait
{
@ -12,13 +13,17 @@ trait PayloadParserTrait
*
* @return array
*/
private function parseJson($json)
private function parseJson($json, $response)
{
$jsonPayload = json_decode($json, true);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new ParserException('Error parsing JSON: '
. json_last_error_msg());
throw new ParserException(
'Error parsing JSON: ' . json_last_error_msg(),
0,
null,
['response' => $response]
);
}
return $jsonPayload;
@ -31,7 +36,7 @@ trait PayloadParserTrait
*
* @return \SimpleXMLElement
*/
private function parseXml($xml)
protected function parseXml($xml, $response)
{
$priorSetting = libxml_use_internal_errors(true);
try {
@ -41,7 +46,12 @@ trait PayloadParserTrait
throw new \RuntimeException($error->message);
}
} catch (\Exception $e) {
throw new ParserException("Error parsing XML: {$e->getMessage()}", 0, $e);
throw new ParserException(
"Error parsing XML: {$e->getMessage()}",
0,
$e,
['response' => $response]
);
} finally {
libxml_use_internal_errors($priorSetting);
}