-
Notifications
You must be signed in to change notification settings - Fork 115
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
JSON stringified error does not contain message #20
Comments
As far as I know, this is the way JavaScript itself works (try running |
@Jokero any interest in making a PR for this? |
I want to make a PR in the future to completely update this module. https://github.com/Jokero/http-error/blob/master/index.js |
Ok, @Jokero , though this module's interface is part of Koa, so any major changes please make sure you discuss with the Koa project first. |
i'm 👍 to making everything stringify-able, particularly here's of an example of us hacking around it: https://github.com/stream-utils/raw-body/blob/1e45346682da648ab02e5c92577de10caab905ac/index.js#L167 i don't see how this would break backwards incompatibility, but we could just add it to koa v2 |
@jonathanong As workaround I created separate npm module https://github.com/Jokero/http-error-constructor Every property instead of It's possible to create error with custom status code (there is var err = new HttpError.BadRequest();
console.log(err instanceof HttpError); // true
console.log(err instanceof HttpError.BadRequest); // true
It fixes another issue. |
@jonathanong what do you think if we just added a |
In my app I use
res.status(err.status).send(err)
to send error.send
usesJSON.stringify
for objects. Stringified error does not containmessage
.Example:
The text was updated successfully, but these errors were encountered: