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

Properly handling status codes / errors? #39

Closed
charliecode opened this issue Aug 7, 2018 · 9 comments
Closed

Properly handling status codes / errors? #39

charliecode opened this issue Aug 7, 2018 · 9 comments
Assignees

Comments

@charliecode
Copy link

What is the best way to handle status codes / errors?

I don't see anything in the docs about errors. I'm most interested in 500 status codes coming from MWS servers so I know I can retry. The problem is I cannot replicate a 500 status code from MWS. I'm also not sure how you're handling 500 status codes. The only place I've been able to find the status codes MWS returns is when a successful "response" is sent back in the "lastResponse.statusCode. When an "error" is sent back it's missing the status code. The only thing available for the "error" is the "code" which can be different depending on the API your calling. Does the "code" sent back in the "error" always correspond to the api doc error handling? Is there a better way for me to search for status codes rather than code messages? Does a 500 status code return an "error" or a "response"? Thanks so much for your help!

@bhushankummar
Copy link
Owner

@charliecode
We are working on this. We will update you back ASAP.

@bhushankummar bhushankummar self-assigned this Sep 4, 2018
@charliecode
Copy link
Author

Wondering what I can do to help make some progress with this. I'm looking through your code now trying to figure out where and how I can return status codes. Any pointing in the right direction is greatly appreciated, thanks so much for this awesome library, it's helped me out a ton.

@charliecode
Copy link
Author

I just tested this on my system and it successfully sent back the statusCode in an error response. Not sure if anything else should be done to handle this correctly but here it is for what it's worth. In AmazonMwsResource.js in the processResponseType() you can add the following below line # 185, "items.ErrorResponse.Error.statusCode = res.statusCode;". For me this successfully sends back Amazon's res statusCode, I believe.

@charliecode
Copy link
Author

Actually this would work better. In AmazonMwsResource.js in the processResponseType() you can add the following below line # 185,

if (items.ErrorResponse) {
items.ErrorResponse.Error.statusCode = res.statusCode;
}

@charliecode
Copy link
Author

Actually again lol, maybe it's better to add "errorResponse.statusCode = res.statusCode;" below line 236.

@bhushankummar
Copy link
Owner

@charliecode
Well, I have already done it. But I was not able to regenerate same error.
Can you please check for development branch and confirm that it's working as expected?

@charliecode
Copy link
Author

@bhushankumarl
It is working as expected. I simulated an error by leaving out one of the required parameters for the MWS request I am making. I see the StatusCode on both errors and normal successful requests, which is great. So I believe you can push to 'master' and add to NPM.

@charliecode
Copy link
Author

charliecode commented Sep 12, 2018

@bhushankumarl Have you had a chance to load this change live to NPM? I would really like to add this functionality to my project, thanks so much for you help with this. This project is awesome!

@bhushankummar
Copy link
Owner

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

No branches or pull requests

2 participants