errors icon indicating copy to clipboard operation
errors copied to clipboard

"Fix" custom error messages on more recent versions of Node

Open myndzi opened this issue 9 years ago • 1 comments

The docs here: https://nodejs.org/api/errors.html#errors_error_capturestacktrace_targetobject_constructoropt

claim that the target of the captureStackTrace method's .toString method will be used to generate the error message line, but it doesn't seem to be so, at least on versions 5.3 and 5.9.1. Instead, just the vague string 'Error' is produced. This patch will replace either 'Error' or '[Object object]' at the start of the line with the custom message, instead of just '[Object object]'. It's worth noting that the test suite fails on recent versions of nodes for this reason, so I didn't need to add any tests to validate this patch -- they are already there.

Closes #14

myndzi avatar Mar 26 '16 16:03 myndzi

@myndzi thanks for this report and merge request.

It appears there's already a node issue for this: https://github.com/nodejs/node/issues/5675 However it's currently marked as a doc issue. As you can see in my recent update to that issue, I would assert this is a (regression), bug... We'll see what they say.

In the meantime I have no problems merging your "workaround". However can I ask one thing -- would you mind just adding a TODO comment with a link to the node bug so that we can easily identify the root cause?

bodenr avatar Mar 31 '16 14:03 bodenr