mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
fix exception handler
This commit is contained in:
parent
2b1569d939
commit
e671cc61cc
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user