LibreTube/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt
2022-08-02 13:05:27 +02:00

15 lines
552 B
Kotlin

package com.github.libretube.util
import com.github.libretube.preferences.PreferenceHelper
class ExceptionHandler(
private val defaultExceptionHandler: Thread.UncaughtExceptionHandler?
) : Thread.UncaughtExceptionHandler {
override fun uncaughtException(thread: Thread, exc: Throwable) {
// save the error log
PreferenceHelper.saveErrorLog(exc.stackTraceToString())
// throw the exception with the default exception handler to make the app crash
defaultExceptionHandler?.uncaughtException(thread, exc)
}
}