-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
doc: fix Error:captureStackTrace description #14150
Conversation
doc/api/errors.md
Outdated
@@ -221,8 +221,7 @@ Error.captureStackTrace(myObject); | |||
myObject.stack; // similar to `new Error().stack` | |||
``` | |||
|
|||
The first line of the trace, instead of being prefixed with `ErrorType: | |||
message`, will be the result of calling `targetObject.toString()`. | |||
The first line of the trace will be prefixed with `ErrorType.name: message`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be myObject.name
if myObject.message
doesn't exist, or ${myObject.name}: ${myObject.message}
if it does. I think it's the ErrorType
that's tripping me up a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
I'd assume this paragraph and the snippet above it have "evolved" separately and have become disjoint.
the actual formula is:
`${myObject.name || 'Error'}${String(myObject.message) ? (': ' + String(myObject.message)) : ''}`
But IMHO `${myObject.name}: ${myObject.message}`
is good enough
@refack , @TimothyGu thanks for the review. I've fixed the line. |
PR-URL: nodejs#14150 Fixes: nodejs#5675 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Kunal Pathak <kunal.pathak@microsoft.com>
Landed in 7f26a29 |
is this relevant to behavior in 6.x? |
ping |
Hi everyone!
I fixed the wrong sentence in the
Error.captureStackTrace(targetObject[, constructorOpt])
part of api/errors doc.Fixes: #5675
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)