fix: add res.status to error message#36
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where error messages could be incomplete when res.statusText is undefined by including the HTTP status code in error messages.
- Updates error message construction to include both status code and status text
- Handles cases where
res.statusTextmay be undefined by providing a fallback
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| } | ||
|
|
||
| const err = new Error(res.statusText) | ||
| const err = new Error(`${res.status} ${res.statusText || ''}`) |
There was a problem hiding this comment.
The error message format could result in trailing whitespace when res.statusText is undefined. Consider using a more explicit format like ${res.status}${res.statusText ? ': ' + res.statusText : ''} to avoid unnecessary spaces.
| const err = new Error(`${res.status} ${res.statusText || ''}`) | |
| const err = new Error(`${res.status}${res.statusText ? ': ' + res.statusText : ''}`) |
if |
no, before the error message is empty, after the error message is |
|
left a comment in that PR |
cause res.statusText can be undefined