Uh oh!
There was an error while loading. Please reload this page.
errors: make sure all Node.js errors show their properties - #29677
errors: make sure all Node.js errors show their properties#29677BridgeAR wants to merge 2 commits into
Conversation
cf78c7e to
fcef9d0CompareThis improves Node.js errors by always showing the attached properties when inspecting such an error. This applies especially to SystemError. It did often not show any properties but now all properties will be visible. This is done in a mainly backwards compatible way. Instead of using prototype getters and setters, the property is now set directly on the error.
fcef9d0 to
aa3b02bComparenodejs-github-bot
commented
Sep 23, 2019
joyeecheung
commented
Sep 24, 2019
One question regarding |
BridgeAR
commented
Sep 24, 2019
I personally think we should, since it's an actual property and the user would otherwise not know about that. It's possible to check for the code in that case. It is of course somewhat redundant but I think for now we should just show both. |
Uh oh!
There was an error while loading. Please reload this page.
Trott
commented
Oct 1, 2019
@nodejs/collaborators This could use some reviews. |
It is not clear why some operations are done in a specific way. This should be clarified to potentially simplify the implementation.
BridgeAR
commented
Oct 1, 2019
@mcollina PTAL (I added a TODO comment as suggested by @jasnell#29677 (comment)). |
nodejs-github-bot
commented
Oct 1, 2019
nodejs-github-bot
commented
Oct 1, 2019
Trott
commented
Oct 2, 2019
Wondering if this might be more breaking than we realize. Out of caution, here's a CITGM (with debian-8 unchecked for $REASONS): https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/2027/ (queued) |
| '[Error [ERR_SCRIPT_EXECUTION_INTERRUPTED]: ' + | ||
| 'Script execution was interrupted by `SIGINT`] {', | ||
| " code: 'ERR_SCRIPT_EXECUTION_INTERRUPTED'", | ||
| '}', |
There was a problem hiding this comment.
why did this test in particular need to change? is there something unusual about how this test works?
There was a problem hiding this comment.
The difference is that the code property became enumerable. That seems important so that users become aware that it's an actual property, not only part of .stack.
Mostly we just do not check what properties exist but only verify that specific properties contain specific values.
There was a problem hiding this comment.
In other words, because no other tests inspect .stack this way?
There was a problem hiding this comment.
It's not the stack that is changed here. It's the output when inspecting the error (e.g., using console.log or util.inspect). The reason is that only enumerable properties are inspected by default and others are ignored.
We rarely inspect errors in tests. Mostly we just check for the properties existence and their values. That also works with non-enumerable properties.
Trott
commented
Oct 3, 2019
CITGM looks good. |
Trott
commented
Oct 3, 2019
@nodejs/tsc What's the semver-ity of this? Patch? Major? Minor even? |
@Trott I would say it's a patch, since no property was added or removed and they are also writable and configurable as before. We might call it semver-minor due to the change in enumerable properties but it seems more like a fix to me. We do enumerable properties on other system errors and also on other error types. Just the |
Trott
commented
Oct 3, 2019
Going to land as patch. semver-* label can always be added after landing if anyone disagrees. |
This improves Node.js errors by always showing the attached properties when inspecting such an error. This applies especially to SystemError. It did often not show any properties but now all properties will be visible. This is done in a mainly backwards compatible way. Instead of using prototype getters and setters, the property is now set directly on the error. PR-URL: #29677 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Trott
commented
Oct 3, 2019
Landed in 500720f |
This improves Node.js errors by always showing the attached properties when inspecting such an error. This applies especially to SystemError. It did often not show any properties but now all properties will be visible. This is done in a mainly backwards compatible way. Instead of using prototype getters and setters, the property is now set directly on the error. PR-URL: #29677 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This improves Node.js errors by always showing the attached properties
when inspecting such an error. This applies especially to SystemError.
It did often not show any properties but now all properties will be
visible.
This is done in a mainly backwards compatible way. Instead of using
prototype getters and setters, the property is now set directly on the
error.
Note: the custom inspect function is necessary for the SystemError to keep the old getter/setter behavior intact .
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes