-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Check if Error object has stack property. Fixes #34. #38
Check if Error object has stack property. Fixes #34. #38
Conversation
If you |
signale.js
Outdated
@@ -192,7 +192,7 @@ class Signale { | |||
} | |||
} | |||
|
|||
if (msg instanceof Error) { | |||
if (msg instanceof Error && typeof msg.stack !== 'undefined') { |
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.
Nice approach! We could also rely upon type conversion and prevent any falsy value from making it through, that way rare cases where stack
is set, for example, to null
are covered too;
if (msg instanceof Error && msg.stack) {
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.
A minor tweak and it is good to go! Thank you for taking the time to contribute : )
As per @klauscfhq request, the check now relies upon type conversion to prevent any falsy value from making it through.
@passcod can you provide an example of that? I tried to reproduce your Obviously this is the smallest tweak ever committed, so I guess that any further improvement would be welcome. |
Thank you! |
@robertoschiavone ah, nevermind, yes you're correct. Thanks for the PR :) |
This PR addresses the problem described in #34
When trying to log an Error with an undefined stack trace, now
signale
correctly logs the error name and ignores thestack
property.Before:
After: