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
I'm not sure exactly how this works and if this is the right place to raise the issue but:
In the browser (chrome)
console.error(newError);// Logs the error and an expandable stack trace.Error(…)(anonymousfunction) @ VM297:2InjectedScript._evaluateOn @VM174:878InjectedScript._evaluateAndWrap @ VM174:811InjectedScript.evaluate @ VM174:667
In node:
console.error(newError)[Error]// To properly show the stack trace I would have to console.error the stack.// In the browser this causes the stack to be visible twice.console.error((newError).stack)
Is it possible to make it so that node will automatically add stack traces on console.error?
This will impact behaviour of console.warn as well since in the browser, even that prints the stack trace.
Also, so does console.log in chrome/firefox/etc.
So, from what I gather, it's the way util.format handles Error objects that needs to change.
I would also like this, but on the other hand I'm sure there are a lot of libraries out there that use console.error to output text to stderr (I often do it myself in my utility scripts) so it would definitely be semver-major.
Yea I think it should be a change to util.inspect though for Errors. I think that would make the change less breaking to the ecosystem (although still a major change)
Activity
julianduque commentedon Jan 7, 2016
I like this suggestion
zeusdeux commentedon Jan 8, 2016
This will impact behaviour of
console.warnas well since in the browser, even that prints the stack trace.Also, so does
console.login chrome/firefox/etc.So, from what I gather, it's the way
util.formathandlesErrorobjects that needs to change.evanlucas commentedon Jan 8, 2016
I always forget to add the check for
err.stack || errand it drives me nuts. I would be +1 on this, but it would be a semver-major change.targos commentedon Jan 8, 2016
I would also like this, but on the other hand I'm sure there are a lot of libraries out there that use
console.errorto output text tostderr(I often do it myself in my utility scripts) so it would definitely be semver-major.evanlucas commentedon Jan 8, 2016
Yea I think it should be a change to util.inspect though for Errors. I think that would make the change less breaking to the ecosystem (although still a major change)
zeusdeux commentedon Jan 8, 2016
I agree that the change should be in
util.inspect. The way Errors are displayed could be changed informatError.Edit: I can pick this up and make the changes in
formatErrorif someone hasn't already picked this up.Edit 2: Had some time so got it done.
GeorgeBailey commentedon Jan 8, 2016
Certainly
util.inspectis the right place. +1 this change for the next major version.util: Change how Error objects are formatted