Skip to content
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

Merged
merged 2 commits into from
Jun 3, 2021

Conversation

Mykelo
Copy link
Contributor

@Mykelo Mykelo commented Jun 1, 2021

What was the problem?

Errors returned by the SDK were kind of useless, because code and message fields were undefined.

Fix

The code assumed that Amazon returns an error as a single object with code and message fields, but actually they return it as an array of such objects. I made small changes to resolve this issue.

Copy link
Contributor

@moltar moltar left a 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?

const { response } = error
if (response) {
const { headers, data } = response
const modelError = data.errors[0] || {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@moltar
Copy link
Contributor

moltar commented Jun 2, 2021

@Mykelo also tests seem to fail.

@Mykelo
Copy link
Contributor Author

Mykelo commented Jun 2, 2021

@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.

@moltar
Copy link
Contributor

moltar commented Jun 3, 2021

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.

@moltar moltar merged commit 55b64b5 into ScaleLeap:master Jun 3, 2021
github-actions bot pushed a commit that referenced this pull request Jun 3, 2021
## [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))
@github-actions
Copy link
Contributor

github-actions bot commented Jun 3, 2021

🎉 This PR is included in version 3.5.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants