bugsnag / bugsnag-react-native

Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
https://docs.bugsnag.com/platforms/react-native
MIT License
370 stars 121 forks source link

Can't use custom error classes #405

Closed cristianoccazinsp closed 5 years ago

cristianoccazinsp commented 5 years ago

Description

While calling notify, it seems like it is not possible to use custom error classes (that inherit from Error).

Issue

I've defined the following error classes:

export class Warning extends Error{
  name = "Warning";
  displayName = "Warning";
}
Warning.constructor.name = "Warning";

export class Info extends Error{
  name = "Info";
  displayName = "Info";
};
Info.constructor.name = "Info";

However, when calling bugsnag.notify(new Info("some info")), it will always end up in the bugsnag console as "I [Native code]: 0".

My first guess is that the name gets mangled after minification, but I was hoping that setting constructor.name would fix it since that's what is used by the Report constructor here (https://github.com/bugsnag/bugsnag-react-native/blob/master/src/Bugsnag.js#L385)

Any ideas how can I send custom error names?

Environment

Library versions: "bugsnag-react-native": "2.23.1"

cristianoccazinsp commented 5 years ago

Ended up just setting the errorClass property on the report object. Looks like a babel issue just uglifying everything.