Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

doc: fix Error:captureStackTrace description #14150

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Copy link
Member

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.

Copy link
Contributor

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


The optional `constructorOpt` argument accepts a function. If given, all frames
above `constructorOpt`, including `constructorOpt`, will be omitted from the
Expand Down