REST API does not throw HTTP error message/code
See original GitHub issueWhen 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:
shopify.customer.create({
first_name: 'John',
last_name: 'Doe',
email: 'alreadyexisting@email.com'
});
will throw the following error:
error HTTPError: Response code 422 (Unprocessable Entity) {
name: 'HTTPError',
code: undefined,
timings: {
start: 1614248835511,
socket: 1614248835511,
lookup: 1614248835691,
connect: 1614248835728,
secureConnect: 1614248835764,
upload: 1614248835770,
response: 1614248836439,
end: 1614248836441,
error: undefined,
abort: undefined,
phases: {
wait: 0,
dns: 180,
tcp: 37,
tls: 36,
request: 6,
firstByte: 669,
download: 2,
total: 930
}
}
}
The code is undefined, error is undefined. Any workaround to access the errors that Shopify Admin API actually returns. In this case, the errors are:
{
"errors": {
"email": [
"has already been taken"
]
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Best Practices for REST API Error Handling - Baeldung
Learn about some of the best practices for handling REST API errors ... an HTTP status code of 500 when our BookNotFoundException is...
Read more >Error handling for the REST API - BMC Documentation
When responding to requests, the REST API uses some of the HTTP ... 400, Bad Request, This code is used if the request...
Read more >How implement error in Rest API? - php - Stack Overflow
There are a couple of concerns that you're dealing with in here. First one is error handling, whilst the second one is error...
Read more >REST API error handling - IBM
The REST API reports errors by returning an appropriate HTTP response code, for example 404 (Not Found), and a JSON response. Any HTTP...
Read more >Rails API Painless Error Handling and Rendering
What if I told you there was a way to abstract away messy and repetitive error raising and response rendering in your Rails...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

No plan at the moment. If it is requested by a consistent amount of users we might consider it.
Use
error.response.body. Whereerroris your error.