Skip to content

Instantly share code, notes, and snippets.

@selmanon
Created October 5, 2022 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selmanon/4211f176653686cd96e1bea7547093d9 to your computer and use it in GitHub Desktop.
Save selmanon/4211f176653686cd96e1bea7547093d9 to your computer and use it in GitHub Desktop.
RxJavaPlugins.setErrorHandler { e: Throwable ->
when (e) {
is UndeliverableException -> logger.logException(e)
is IOException -> logger.logException(e) // fine, irrelevant network problem or API that throws on cancellation
is InterruptedException -> logger.logException(e) // fine, some blocking code was interrupted by a dispose call
is NullPointerException -> logger.logException(e) // that's likely a bug in the application
is IllegalArgumentException -> logger.logException(e) // that's likely a bug in the application
is IllegalStateException -> logger.logException(e) // that's a bug in RxJava or in a custom operator
else -> {
logger.logException(e)
currentThread().uncaughtExceptionHandler!!.uncaughtException(
currentThread(),
e
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment