-
Notifications
You must be signed in to change notification settings - Fork 518
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
Standard err serializer: better support for caused errors #200
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -985,7 +985,7 @@ Logger.stdSerializers.res = function res(res) { | |
|
||
/* | ||
* This function dumps long stack traces for exceptions having a cause() | ||
* method. The error classes from | ||
* method or a cause property. The error classes from | ||
* [verror](https://github.com/davepacheco/node-verror) and | ||
* [restify v2.0](https://github.com/mcavage/node-restify) are examples. | ||
* | ||
|
@@ -995,10 +995,16 @@ Logger.stdSerializers.res = function res(res) { | |
function getFullErrorStack(ex) | ||
{ | ||
var ret = ex.stack || ex.toString(); | ||
if (ex.cause && typeof (ex.cause) === 'function') { | ||
var cex = ex.cause(); | ||
if (ex.cause) { | ||
var cex; | ||
if (typeof (ex.cause) === 'function') { | ||
cex = ex.cause(); | ||
} | ||
if (typeof (ex.cause) === 'object') { | ||
cex = ex.cause; | ||
} | ||
if (cex) { | ||
ret += '\nCaused by: ' + getFullErrorStack(cex); | ||
ret += '\ncaused by ' + getFullErrorStack(cex); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? How does this "integrate better with the default stack trace formatter"? I'm not familiar with the "default" stack trace formatting you are referring to. Also, if we decide to keep this "caused by" change, there is at least one test case that will need to be updated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default V8 stack trace formatter, that's what I'm talking about. |
||
} | ||
return (ret); | ||
|
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.
perhaps
else if
hereThere 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.
No problem, it could even be a
switch
statement.