-
Notifications
You must be signed in to change notification settings - Fork 205
-
Notifications
You must be signed in to change notification settings - Fork 205
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
BeforeSend.run report.getError().getException() returns BugsnagException #577
Comments
getException Returns the thrown Throwable. https://docs.bugsnag.com/platforms/android/customizing-error-reports/#getexception |
Hi @M66B Thanks for the feedback! Yes, this is definitely an inconsistency between the behaviour and the documentation but I'm not sure we'd be able to implement your proposed solution as in the general case the error report may be stored and delivered later (e.g. if the app is offline or crashes before the report can be sent). In these cases I don't think we can easily re-create the original exception using the right class. We'll discuss this and agree the way forward, which may just be to align the documentation with the true behaviour if that's the best we can do. |
I think this is rather disappointing, especially because it is a breaking change. I had lots of exceptions unnecessary reported due to this change, hitting the rate limit. |
Is there any news on this or am I stuck on an old Bugsnag version? |
@M66B - unless I misunderstand your use case, you shouldn't need to stay on the older version. To summarise, the behaviour is that a However this return value should be null-checked before use as it will be null if:
|
Thanks for clarifying @tomlongridge I have moved my custom checks from beforeSend to beforeNotify and switched to error.getException().getCause(). Can you please confirm this is what you meant? May I suggest to change the return type of getException to BugsnagException ? |
@M66B - yes, that's correct. We're looking at a documentation update to clarify this. |
Unfortunately, things do not work as expected: beforeNotify seems not to be called, so I had to revert the referenced commit to downgrade Bugsnag again :-( What can be the cause of this? Note that beforeNotify was called in version 4.17.2, which I know for sure because extra tab pages are being added. In fact I discovered this by missing these extra tab pages. |
The changes referenced look OK to me. One thing to mention is that only JVM errors trigger the Have you been able to determine that |
The problem appears to be that calling Bugsnag.notify results in an empty error.getException().getCause() in beforeNotify. Since the app catches most exceptions and reports these with Bugsnag.notify (which will filter a number of exceptions) this is not going to work :-( |
I didn't test this, but I am wondering if setIgnoreClasses does work in this case. Not that it will be useful because custom filtering is done to filter exception 'contains' or 'startsWith' getMessage. |
Bugsnag has been quite useful, but I am considering recent versions as broken. In any case there were undocumented breaking API changes. Therefore this issue should not be closed. Note that I don't mean this in a bad way. |
Proposal: why not add a callback for custom filtering based on the original exception? |
Apologies - having investigated this further, it appears that the This change was necessary to allow the callbacks to work consistently with NDK errors and with errors that couldn't be sent at the time of the crash, so are serialised to file and sent later. Any logic that relies on the type of the exception for pre-4.18 implementations, cannot be guaranteed to work as expected for these scenarios as the exception won't be of the original type. We are looking at straightening this out in a future major release so that access to the original In the meantime, I would suggest you either use the |
No worries @tomlongridge As developer I understand that development isn't easy! Unfortunately, getExceptionName won't work in my case because the exception message needs to be checked as well and sometimes also the underlying cause exception. Background: JavaMail throws MessagingException for everything and anything and the custom logic is meant to filter things away that are no problem (like connection errors). Maybe I can use the main thread last chance exception handler to do this, but it would be better if there was a working "before" hook for this in Bugsnag. I guess this issue needs to be reopened until there is a solution for this. |
We're reworking this area in the next major release and can confirm that the use case you describe will be supported by the changes. |
@mattdyoung Thanks for letting me know! |
The interface has now been reworked and improved in v5.0.0, so you can now get a reference to the actual |
Thanks for actively letting me know @mattdyoung |
Please note that we've made a number of improvements to the interface for v5.0.0, some of which are breaking changes so please refer to the upgrade guide: |
I was already aware of that, but thanks @mattdyoung. If you like, I can report about my migration experience. I will attempt that likely next week. |
I can't upgrade because this issue is not solved and the workaround for it cannot be used anymore: If you are interested in my upgrade experience, please see this patch (untested): I have one question: does resumeSession/pauseSession start/stop sending events to the Bugsnag server? If not, what is the right way to dynamically enable/disable reporting (privacy!). Suggestion: add Bugsnag.leaveBreadcrumb with Map<String, String> as parameter too. In my case all Bugsnag logic is at one place, but that might not always be the case, causing extra work to upgrade leaveBreadcrumb calls. |
Hi @M66B The #533 is solved, which has been discussed separately under that issue. Re this question:
The client sends both sessions and events to Bugsnag. Event are the error reports whereas sessions are just used in conjunction with events to calculate what proportion of sessions resulted in an unhandled exception (the stability score). When initializing the If you wanted to dynamically stop sending data to Bugsnag after initialization, this can be done by using conditional logic in the Thanks for all the feedback! |
@mattdyoung it has been done, thanks for the help! |
@mattdyoung everything seems to work as expected! |
Expected behavior
return original exception
Observed behavior
returns BugsnagException
Steps to reproduce
Use version 4.18+
Version
4.18+
Additional information
The return type of report.getError().getException() should either be a Throwable or a BugsnagException. Throwable is preferred because instanceof can be used to quickly and safely determine the exception type, whereas BugsnagException requires a string compare on the exception name.
The text was updated successfully, but these errors were encountered: