You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Shopify is a bit inconsistent with their error responses. In particular: while calling cancelOrder I found that they don't return an array of errors, but just a single line attribute error.
The Handler specifically looks for the errors key in the response JSON, and returns an empty array by default if it's not found. This led me to getting validation exceptions like this:
Validation failed due to: [] {"exception":"[object] (Signifly\Shopify\Exceptions\ValidationException(code: 0): Validation failed due to: [] ...
which obviously isn't great for trying to handle errors.
This could be resolved with something like the following:
if ($response->status() === 422) {
$errors = $response->json('errors', []);
if (empty($errors)) {
$errors = $response->json('error', []);
if (!empty($errors)) {
$errors = [$errors];
}
}
thrownewValidationException($errors);
}
but I didn't want to impose with another PR, so leaving this here as an issue for you to determine the best solution.
The text was updated successfully, but these errors were encountered:
Shopify is a bit inconsistent with their error responses. In particular: while calling cancelOrder I found that they don't return an array of
errors
, but just a single line attributeerror
.The Handler specifically looks for the
errors
key in the response JSON, and returns an empty array by default if it's not found. This led me to getting validation exceptions like this:which obviously isn't great for trying to handle errors.
This could be resolved with something like the following:
but I didn't want to impose with another PR, so leaving this here as an issue for you to determine the best solution.
The text was updated successfully, but these errors were encountered: