-
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
Inconsistent error property enumerability #49
Comments
If it helps guide what the right behavior should be, the JSON representation of a normal
Consistency with native errors might make sense, although for the purposes of snapshot testing I wish all of the properties were enumerable. |
Ah, that's a good point. I can see either way, but it makes sense that it should be consistent. |
Related past discussion: #20 |
So the issue is that the properties you are getting in the output are just the ones we are touching inside the factory and JSON.stringify ignores properties on the prototype. All the properties we add are enumerable so it seems like the issue here is that Json.stringify doesn't print out properties on the prototype, hm... I'm not sure what a good solution would be. Does anyone have some thoughts on this? |
Actually for some reason message is now enumerable when for a classic error it is not. And statusCode is not enumerable. This is really weird, and it seems to have been done because someone is trying to JSON.stringify it. But it should not be the problem of http-errors |
Hi everyone, as an update, the 3.0 release will address this by setting all properties as non-enumerable, which matches how ECMA-262 works with errors: https://tc39.es/ecma262/#sec-error-message |
You would expect these usages to log identically:
They actually output this:
For context, I am attempting to do snapshot testing of errors that have been created various ways and am having many surprises.
The text was updated successfully, but these errors were encountered: