Closed haseebanwar closed 3 years ago
Use error.response.body
. Where error
is your error.
@lpinca does the error object contains any code or name that tells if the error is from Shopify API i.e. error.name
is ShopifyAdminError
so I can check in the catch block if the error is from Shopify API. Like this:
try {
const customer = await shopify.customer.get(customerId);
const anotherAsync = await otherClient.get();
} catch(error) {
if (error.name === 'ShopifyAdminError') {
// do something
} else {
// do something else
}
}
@haseebanwar no, we just return the error from got
(the HTTP client used by shopify-api-node
) as is.
I understand it is not clean, but in your example you could use two different try...catch
, one for each await
expression.
@lpinca got it, thanks. Any plan of implementing such logic in the future?
No plan at the moment. If it is requested by a consistent amount of users we might consider it.
When there is an
HTTPError
, the error object thrown does not contain any info about the error. For instance, creating a customer with an existing email like:will throw the following error:
The code is
undefined
, error isundefined
. Any workaround to access the errors that Shopify Admin API actually returns. In this case, the errors are: