Extended Error Info
See original GitHub issueWhen we notify an error to bugsnag using bugsnag.notify(error)
, by default it shows Error name, stack trace and message in Bugsnag App.
If the error is a custom Error (extended), which may include more info, that data is not visible anywhere (not sure if it’s captured in the first place).
For example, consider following error class -
EError.js
module.exports = class EError extends Error {
constructor (message, statusCode, details) {
super(message);
this.statusCode = statusCode || 500;
this.details = details;
this.name = "EError" + (statusCode ? ` (${statusCode})` : "");
}
};
I have 2 additional properties statusCode
and details
, which I want to be included in Bugsnag error. If I pass the error (instanceof EError) to bugsnag notify, the extra properties are no where to be found in the captured Bugsnag error.
let details = { sess: "7e5c1c4a-11e3-41a2-a935-c1a0068e521b" };
let err = new EError("Bad Email Address", 400, details);
bugsnag.notify(err);
I tried pushing the err as metaData, even then the details and statusCode is no where to be found on bugsnag.
bugsnag.notify(err, { metaData: {err} });
Only message
and name
captured in metadata.
What can I do to capture more info about the error. Not just that this custom error class has more info, most of the libraries has custom error with more details where message would not be sufficient to debug error. E.g check Sequelize Unique Constraint Error, it has so many info which is just lost when captured on Bugsnag.
I’m currently on v6.2.0 of @bugsnag/node
(using with NodeJS v8.11.1)
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Hi @GuillaumeCisco - please could you expand a bit more on this please? Are you able to share a code snippet or a link to an event in your Bugsnag dashboard to demonstrate what you mean? Feel free to write into support@bugsnag.com if you’d prefer 👍
Agree with @enVolt here, getting all the extra enumerable properties from the
Error
object should be the default and it shouldn’t be complex or error prone. Knowing how to handleError
objects properly is something I would expect out of the box.