androidcrashlytics

Crashlytics recordException not working for custom exception with cause parameter included


I need to log an exception to Crashlytics from a Kotlin Result.onFailure.

The following works (where it is a throwable)

FirebaseCrashlytics.getInstance().recordException(it)

This also works

FirebaseCrashlytics.getInstance().recordException(MyCustomException("test message"))

where custom exception is

class MyCustomException(message: String) : Exception(message)

However this doesn't get logged to Crashlytics

FirebaseCrashlytics.getInstance().recordException(MyCustomException(it))

where

class MyCustomException(t: Throwable) : Exception(t)

So it seems that including a cause parameter means it's not logged to Firebase. Anybody know why not?


Solution

  • I since discovered that my exceptions were being logged to Crashlytics. The problem was that they weren't easily discoverable.

    If there's an exception with a cause, only the cause is findable in the Crashlytics Console. For example if I have

    class MyOuterException(t: Throwable) : Exception(t)
    

    and I do

    .recordException(MyOuterException(MyInnerException()))
    

    Then only MyInnerException will be displayed in the list of Exceptions in Crashlytics. Furthermore, even if I search for MyOuterException it won't display any results.