As part of https://github.com/bugsnag/bugsnag-android/pull/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 a BugsnagException if they are not already of that type. This meant that JavaScriptException#toStream() was not invoked when serialising an error report, leading to the name being serialised as com.bugsnag.JavaScriptException, rather than the name of the JS error.
This changeset alters JavaScriptException to inherit BugsnagException, meaning that it is not wrapped in a BugsnagException, and that its custom toStream 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.
Goal
As part of https://github.com/bugsnag/bugsnag-android/pull/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.