Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Merge pull request #137 from bugsnag/better-logging
Browse files Browse the repository at this point in the history
Improve logging clarity for unhandled exceptions
  • Loading branch information
bengourley authored Mar 8, 2018
2 parents e56a87d + c96e7a2 commit ac3b195
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/bugsnag.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function autoNotifyCallback(notifiedError, uncaughtError) {
errorMsg.push(notifiedError.stack);
}
}
errorMsg.push("");
Configuration.logger.error(errorMsg.join('\n'));
}
if (Configuration.onUncaughtError && uncaughtError) {
Expand Down
11 changes: 8 additions & 3 deletions lib/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ var Configuration = {
onUncaughtError: function(err) {
if ((err instanceof Error) && err.domain) {
if (err.domainThrown || err.domainEmitter || err.domainThrown === void 0) {
Configuration.logger.error(err.stack || err);
return process.exit(1);
var context = "";
if (err.domain._bugsnagOptions && err.domain._bugsnagOptions.cleanedRequest) {
context += " at " + err.domain._bugsnagOptions.cleanedRequest.httpMethod
context += " " + err.domain._bugsnagOptions.cleanedRequest.path + ""
}
Configuration.logger.error("Encountered an uncaught error" + context + " terminating…\n" + (err.stack || err));
return process.exit(1);
}
} else {
Configuration.logger.error(err.stack || err);
Configuration.logger.error("Encountered an uncaught error, terminating…\n" + (err.stack || err));
return process.exit(1);
}
},
Expand Down

0 comments on commit ac3b195

Please sign in to comment.