You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The VError() constructor is agnostic on the subject of the new operator: an instance of VError will be created whether the consumer uses the new operator, or simply calls VError() as a regular function.
Unfortunately, due to the way in which Error.captureStackTrace() appears to function, at least in Node 4.6.0, omitting new makes it impossible to elide one of the VError implementation stack frames from the stack output. I tried modifying the code to pass VError as the constructorOpt to captureStackTrace(), but V8 appears to conflate VError the function and VError the constructor in the stack, and elides only the topmost instance.
For those who wish to avoid the need for new, but still want clean stack traces, we could add a new VError.create() factory method. This would accept the same arguments as VError(), but result in a cleaner stack trace.
The text was updated successfully, but these errors were encountered:
The
VError()
constructor is agnostic on the subject of thenew
operator: an instance ofVError
will be created whether the consumer uses thenew
operator, or simply callsVError()
as a regular function.Unfortunately, due to the way in which
Error.captureStackTrace()
appears to function, at least in Node 4.6.0, omittingnew
makes it impossible to elide one of theVError
implementation stack frames from the stack output. I tried modifying the code to passVError
as theconstructorOpt
tocaptureStackTrace()
, but V8 appears to conflateVError
the function andVError
the constructor in the stack, and elides only the topmost instance.For those who wish to avoid the need for
new
, but still want clean stack traces, we could add a newVError.create()
factory method. This would accept the same arguments asVError()
, but result in a cleaner stack trace.The text was updated successfully, but these errors were encountered: