Created
January 15, 2020 01:05
-
-
Save pyeongho/8a50d38c8957a070098b8ebb71ae8ccc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RxJavaPlugins.setErrorHandler { e -> | |
var error : Throwable? = e | |
if (error is UndeliverableException) { | |
error = e.cause | |
} | |
if (error is IOException || error is SocketException) { | |
// fine, irrelevant network problem or API that throws on cancellation | |
return@setErrorHandler | |
} | |
if (error is InterruptedException) { | |
// fine, some blocking code was interrupted by a dispose call | |
return@setErrorHandler | |
} | |
if (error is NullPointerException || error is IllegalArgumentException) { | |
// that's likely a bug in the application | |
Thread.currentThread().uncaughtExceptionHandler | |
.uncaughtException(Thread.currentThread(), error) | |
return@setErrorHandler | |
} | |
if (error is IllegalStateException) { | |
// that's a bug in RxJava or in a custom operator | |
Thread.currentThread().uncaughtExceptionHandler | |
.uncaughtException(Thread.currentThread(), error) | |
return@setErrorHandler | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment