-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Do not stringify errors when logging them #19148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not stringify errors when logging them #19148
Conversation
If we're going to start using this pattern, then it probably wouldn't hurt to also enable the following ESLint rule: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-console-spaces.md |
Converting errors to string drops their stack trace, making it more difficult to debug their actual reason. We can instead pass the error objects as-is to console.warn/error, so that Firefox/Chrome devtools will show both the stack trace of the console.warn/error call, and the original stack trace of the error. This commit also enables the `unicorn/no-console-spaces` ESLint rule, which avoids accidental extra spaces when passing multiple parameters to `console.*` methods.
a1f8e89
to
202b264
Compare
Seems reasonable, added. |
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/b624d1ad21a179f/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/6d3162e0c69d7cc/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/b624d1ad21a179f/output.txt Total script time: 29.09 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/6d3162e0c69d7cc/output.txt Total script time: 50.79 mins
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me, thanks.
Converting errors to string drops their stack trace, making it more difficult to debug their actual reason. We can instead pass the error objects as-is to console.warn/error, so that Firefox/Chrome devtools will show both the stack trace of the console.warn/error call, and the original stack trace of the error.