Closed fny closed 2 years ago
@fny Sure, looks about right. Please submit a PR, and we will merge. Thanks!
Do you all have any preference for what the return types should look like?
Do you all have any preference for what the return types should look like?
Not sure what you mean.
Can you please provide a bit more context?
Thanks!
Right now you all have Promise.reject(error.response.data)
as the returned value for the cases when the server responds with an error.
In the other two cases what do you want to return?
function handleError(error) {
if (error.response) {
// You all have handle this case
return response.data
} else if (error.request) {
// The request was made but no response was received
// What do we return here?
return ...
} else {
// Something happened in setting up the request that triggered an Error
// What do were return here?
return ...
}
}
I don't think there should be any return if there is an error. Throw a custom error object, if the error is specific and needs handling, or just re-throw the original error.
We already have many error classes defined in: https://github.com/ScaleLeap/amazon-mws-api-sdk/blob/master/src/error.ts
@fny have you tested this, can this be closed?
.data
will not be available if the server loses connection to the internet or the MWS servers are down.https://github.com/ScaleLeap/amazon-mws-api-sdk/blob/7ec26308606b7f48dc1dc089177a2509da4281ef/src/http.ts#L318
A few more cases are required to test for a failure.