When passing incorrect parameters, in my example string as the limit, The listAll function in walmart-partner-api-sdk-php/src/Order.php is causing
Fatal error: Call to a member function getStatusCode() on a non-object in /var/www/example/Walmart/vendor/fillup/walmart-partner-api-sdk-php/src/Order.php on line 132
In the code, it currently catches Exception $e like this
} catch (\Exception $e) {
if ($e instanceof RequestException) {
/*
* ListReleased and List return 404 error if no results are found, even for successful API calls,
* So if result status is 404, transform to 200 with empty results.
*/
/** @var ResponseInterface $response */
$response = $e->getResponse();
if (strval($response->getStatusCode()) === '404') {
return [
'statusCode' => 200,
'list' => [
'meta' => [
'totalCount' => 0
]
],
'elements' => []
];
}
throw $e;
} else {
throw $e;
}
}
Problem is $response is NULL. To fix this, I had to add this (not the best fix) fix under $response = $e->getResponse();.
if (!$response) {
echo 'Walmart API SDK Error: ' . $e->getMessage();
exit();
}
Ideally this SDK should be able to catch bad request parameters gracefully. This should be easy to replicate and hopefully not a huge hassle to fix correctly. I hope this helps.
When passing incorrect parameters, in my example string as the limit, The
listAll
function in walmart-partner-api-sdk-php/src/Order.php is causingIn the code, it currently catches Exception $e like this
Problem is $response is
NULL
. To fix this, I had to add this (not the best fix) fix under$response = $e->getResponse();
.Ideally this SDK should be able to catch bad request parameters gracefully. This should be easy to replicate and hopefully not a huge hassle to fix correctly. I hope this helps.