joyent/node — Issue #2589: Request: Error augmented with fileName, lineNumber
Author: chowey
Created: 2012-01-21 23:12:47+00:00
State: open

Currently when an error is thrown, the fileName and lineNumber are printed to stderr, along with the Error.message and Error.stack.

Since it is (from my attempts) impossible to catch these before they go to stderr, this data is lost to the node process.

Can we augment the Error object to include the fileName and lineNumber? I realize this is non-standard behavior per the EMCAScript 5 specification, but it is supported in some browsers (e.g. Firefox).

This is helpful in running eval'd code, for example. A SyntaxError could locate what line number actually caused the SyntaxError, which is currently impossible without forking a child process and massaging the data from the child's stderr.