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

HTTP Status code is not included in error information #181

Closed
lenkan opened this issue Dec 13, 2023 · 0 comments · Fixed by #203
Closed

HTTP Status code is not included in error information #181

lenkan opened this issue Dec 13, 2023 · 0 comments · Fixed by #203
Assignees
Labels
help wanted Extra attention is needed

Comments

@lenkan
Copy link
Collaborator

lenkan commented Dec 13, 2023

Currently, the http status code is not included in the error information then signify client receives a non-OK response. See

if (!res.ok) {
const error = await res.text();
throw new Error(error);
}
.

This means you get a stack trace that does not include any information about the HTTP request and/or response:

Error:
   at SignifyClient.fetch...

I suggest to include the pathname, the status code, statusText in the error description. The response body can be included as a property on the error. For example

new Error(`HTTP ${method} ${pathname} - ${res.status} ${res.statusText}`, { cause: await response.text() });

Or create a new error type and add response body as a property.

class SignifyClientError extends Error {
    ...Some constructor that create appropriate error message and properties.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants