Skip to content

Instantly share code, notes, and snippets.

@amsterdatech
Created January 27, 2021 01:30
Show Gist options
  • Save amsterdatech/9074bfe6edde8270c8b49c4d34c00a91 to your computer and use it in GitHub Desktop.
Save amsterdatech/9074bfe6edde8270c8b49c4d34c00a91 to your computer and use it in GitHub Desktop.
/**
* You can report it using trackEvent or do your own logic, but remember, you are running in the Main Thread.
* Besides, you shouldn't rely on heavy libraries like RxJava, but Coroutines or Executors are easy to follow as well
*/
override fun uncaughtException(thread: Thread, throwable: Throwable) {
try {
analytics(context)
.track {
name = EventName.EXCEPTION
EventName.STACK_TRACE to extractStackTraceInfo(throwable)
EventName.MESSAGE to throwable.message.toString()
EventName.CAUSE to throwable.cause.toString()
}
} finally {
/**
* Dispatch to default Android handler to show system dialog or finish the app (System.exit(0) or Activity.finish())
*/
defaultHandler?.uncaughtException(thread, throwable)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment