-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: error code and message are no longer undefined #134
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Thank you for the contribution.
Thoughts about the SellingPartnerUnknownError
case?
src/helpers/api-error-factory.ts
Outdated
const { response } = error | ||
if (response) { | ||
const { headers, data } = response | ||
const modelError = data.errors[0] || { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mykelo Shall we perhaps return an instance of SellingPartnerUnknownError
here if data.errors[0]
is undefined
?
There is no such error class yet, but we can create one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like a better idea! I implemented it in a new commit and I hope this is what you meant.
@Mykelo also tests seem to fail. |
@moltar there was a problem with tests, because intercepted requests didn't return errors in the format specified by Amazon (here is an example from their repository). I added the required body and tests seem to work now. |
For posterity and documentation purposes, this is the place that defines error shapes: https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#error-response @Mykelo thank you for your contribution. Merging now, should be released shortly. |
## [3.5.1](v3.5.0...v3.5.1) (2021-06-03) ### Bug Fixes * error code and message are no longer undefined ([#134](#134)) ([55b64b5](55b64b5))
🎉 This PR is included in version 3.5.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What was the problem?
Errors returned by the SDK were kind of useless, because
code
andmessage
fields were undefined.Fix
The code assumed that Amazon returns an error as a single object with
code
andmessage
fields, but actually they return it as an array of such objects. I made small changes to resolve this issue.