Skip to content
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

Error.getException() in BeforeNotify subclass is always a subclass of BugsnagException #880

Closed
marosseleng opened this issue May 12, 2020 · 1 comment

Comments

@marosseleng
Copy link

Expected behavior

With the previous version I was using(4.13.0), error.getException() was returning the original root exception. I'd still expect that.

Observed behavior

With 4.22.3 it returns BugsnagException, where cause is the cause of the original root exception, message is the message of the original root exception, however type is BugsnagException.

Steps to reproduce

Just subclass the Exception and either throw it or call Bugsnag.notify().

Version

4.22.3 but might have been there since 4.19.1 (#576)

Additional information

For me this is a breaking change not documented properly. I do instanceOf checks of the error.getException() in BeforeNotify to prevent notifications on some exceptions. I have an interface to mark exceptions that I don't want to report (such as several API response codes) but as BugsnagException is not the implementation of that interface everything is being sent. Moreover, for handled errors I can't rely on error.getException().getCause() because there is often no cause.

@mattdyoung
Copy link

Hi @mseleng

We're aware of this issue and have now reworked and improved this interface in v5.0.0, so you can now get a reference to the actual Throwable via event.originalError in an OnError callback:
https://docs.bugsnag.com/platforms/android/customizing-error-reports/#errors

We'd recommend upgrading to v5.0.0 as we've made the interface more consistent. There are some breaking changes so please refer to the upgrade guide:
https://github.com/bugsnag/bugsnag-android/blob/v5.0.0/UPGRADING.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants