diff --git a/app/src/main/java/com/github/libretube/MyApp.kt b/app/src/main/java/com/github/libretube/MyApp.kt index d9e8dba76..11cfacfd7 100644 --- a/app/src/main/java/com/github/libretube/MyApp.kt +++ b/app/src/main/java/com/github/libretube/MyApp.kt @@ -46,7 +46,8 @@ class MyApp : Application() { /** * Handler for uncaught exceptions */ - val exceptionHandler = ExceptionHandler() + val defaultExceptionHandler = Thread.getDefaultUncaughtExceptionHandler() + val exceptionHandler = ExceptionHandler(defaultExceptionHandler) Thread.setDefaultUncaughtExceptionHandler(exceptionHandler) } diff --git a/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt b/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt index da2e17235..af8185c84 100644 --- a/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt +++ b/app/src/main/java/com/github/libretube/util/ExceptionHandler.kt @@ -1,17 +1,14 @@ package com.github.libretube.util -import android.util.Log import com.github.libretube.preferences.PreferenceHelper -import kotlin.system.exitProcess -class ExceptionHandler : Thread.UncaughtExceptionHandler { +class ExceptionHandler( + private val defaultExceptionHandler: Thread.UncaughtExceptionHandler? +) : Thread.UncaughtExceptionHandler { override fun uncaughtException(thread: Thread, exc: Throwable) { - Log.e("bnyro", exc.stackTraceToString()) - // sav ethe error log + // save the error log PreferenceHelper.saveErrorLog(exc.stackTraceToString()) - // finish the app - System.exit(0) - android.os.Process.killProcess(android.os.Process.myPid()) - exitProcess(0) + // throw the exception with the default exception handler to make the app crash + defaultExceptionHandler?.uncaughtException(thread, exc) } }