This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
fix: make JavaScriptException inherit from BugsnagException #393
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
As part of bugsnag/bugsnag-android#553 the way exceptions are serialised in bugsnag-android was altered. This was to allow the exception name/message to be altered after a
BugsnagException
object has been constructed.As part of this change, the exception serialisation was altered so that when building an error, all
Throwable
objects must be wrapped in aBugsnagException
if they are not already of that type. This meant thatJavaScriptException#toStream()
was not invoked when serialising an error report, leading to the name being serialised ascom.bugsnag.JavaScriptException
, rather than the name of the JS error.This changeset alters
JavaScriptException
to inheritBugsnagException
, meaning that it is not wrapped in aBugsnagException
, and that its customtoStream
implementation will be invoked and the JS error serialised correctly.Tests
Tested manually in the example app and confirmed that
ReferenceError
was the error class and the correct stacktrace was collected.Additional unit test coverage has also been added in the Android PR.