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

Missing response in error details #28

Open
iampeterbanjo opened this issue Feb 24, 2020 · 0 comments
Open

Missing response in error details #28

iampeterbanjo opened this issue Feb 24, 2020 · 0 comments

Comments

@iampeterbanjo
Copy link

iampeterbanjo commented Feb 24, 2020

Given a request and response like the one below:

nock('https://test.cn:443', {"encodedQueryParams":true})
  .post('/user', {"name":"景全安"})
  .reply(400, {
    "code":400,
    "format":"json",
    "message":"{\"error\": \"Parameter \\\"email\\\" was missing from the request\"}"
   });

I would expect that the error thrown in client.js would include the original response object so that it can be handled correctly. But the error that is thrown only includes the code and headers. For example, when logged the error displays as:

Error: POST https://test.cn failed width code(400).

Please note that the message, "Parameter email was missing from the request" does not exist in the error.

This makes it difficult to use this client with APIs that return errors that are not in the header, for example, because of input validation.

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

1 participant