-
Notifications
You must be signed in to change notification settings - Fork 318
Conversation
Ensures that non-2xx response codes return an error
/cc @fb55 This one is kind of important, IMO. |
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.
looks great
lib/clients/public.js
Outdated
} | ||
if (data === null) { | ||
} else if (response.statusCode > 299) { | ||
err = new Error(`HTTP ${response.statusCode} Error`); |
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.
Use the message
from the response here?
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.
Do you mean the statusMessage
from the response
, or the message
from the body
, or both? I'm inclined to try both.
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.
message
from the body. statusMessage
wouldn't be too bad either 🤷♂️
@fb55 I added the body's error message to the Error object's message. I skipped the |
Amazing, thanks a lot! |
What does it do?
Related Issues