Skip to content

Instantly share code, notes, and snippets.

@myungpyo
Created June 3, 2022 11:05
Show Gist options
  • Save myungpyo/d16d49c60cee475bd3a4521992816d69 to your computer and use it in GitHub Desktop.
Save myungpyo/d16d49c60cee475bd3a4521992816d69 to your computer and use it in GitHub Desktop.
// Standalone Coroutine
override fun handleJobException(exception: Throwable): Boolean {
handleCoroutineException(context, exception)
return true
}
public fun handleCoroutineException(context: CoroutineContext, exception: Throwable) {
try {
context[CoroutineExceptionHandler]?.let {
it.handleException(context, exception)
return
}
} catch (t: Throwable) {
handleCoroutineExceptionImpl(context, handlerException(exception, t))
return
}
handleCoroutineExceptionImpl(context, exception)
}
// Deferred Coroutine
protected open fun handleJobException(exception: Throwable): Boolean = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment