-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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:Error:captureStackTrace description inaccurate #5675
Comments
I am not sure I understood the actual problem. Can you please explain what the expected result be? |
? The problem is that the behavior of the function is not as documented. In the code I gave |
Okay, this was introduced in 7e2235a. cc @chrisdickinson |
I would assert this is a bug (regression), unless the behavior has intentionally changed in more recent versions of node. For example... stacks.js function MyError() {
Error.captureStackTrace(this, MyError);
}
MyError.prototype.toString = function() {
return "My error"
}
console.log(new MyError().stack) Now testing behavior with node 0.10.25 and node 4.4.1: boden@ubuntu:/tmp/errors$ node -v && node ./stacks.js && node4 -v && node4 ./stacks.js
v0.10.25
My error
at Object.<anonymous> (/tmp/errors/stacks.js:9:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
v4.4.1
Error
at Object.<anonymous> (/tmp/errors/stacks.js:9:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
boden@ubuntu:/tmp/errors$ As shown above, in node 0.10.25 the value of toString() is used for stack (e.g. There are existing modules which depend on node's |
@bodenr Try As to |
See also e2f47f5698? But, what @bnoordhuis said, you need have |
Anyone from @nodejs/documentation want to submit the doc fix to close this issue? Alternatively, put a |
So currently the docs are wrong 224 | The first line of the trace, instead of being prefixed with `ErrorType:
225 | message`, will be the result of calling `targetObject.toString()`. Should probably be 224 | The first line of the trace will be prefixed with `ErrorType.name: message`. |
From at least Node 4.2 the documentation says:
This test program:
proves the description incorrect. The first line is produced by
deps/v8/src/messages.js
inErrorToStringDetectCycle
from thename
andmessage
properties oftargetObject
with this logic:where
name
defaults to"Error"
andmessage
defaults to""
.I'm not good at user-facing technical documentation so I'd rather not try to craft replacement text for something that complex.
The text was updated successfully, but these errors were encountered: