mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +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
|
* Handler for uncaught exceptions
|
||||||
*/
|
*/
|
||||||
val exceptionHandler = ExceptionHandler()
|
val defaultExceptionHandler = Thread.getDefaultUncaughtExceptionHandler()
|
||||||
|
val exceptionHandler = ExceptionHandler(defaultExceptionHandler)
|
||||||
Thread.setDefaultUncaughtExceptionHandler(exceptionHandler)
|
Thread.setDefaultUncaughtExceptionHandler(exceptionHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
package com.github.libretube.util
|
package com.github.libretube.util
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.github.libretube.preferences.PreferenceHelper
|
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) {
|
override fun uncaughtException(thread: Thread, exc: Throwable) {
|
||||||
Log.e("bnyro", exc.stackTraceToString())
|
// save the error log
|
||||||
// sav ethe error log
|
|
||||||
PreferenceHelper.saveErrorLog(exc.stackTraceToString())
|
PreferenceHelper.saveErrorLog(exc.stackTraceToString())
|
||||||
// finish the app
|
// throw the exception with the default exception handler to make the app crash
|
||||||
System.exit(0)
|
defaultExceptionHandler?.uncaughtException(thread, exc)
|
||||||
android.os.Process.killProcess(android.os.Process.myPid())
|
|
||||||
exitProcess(0)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user