Rename UncaughtExceptionHandler

This commit is contained in:
tzugen 2021-11-16 18:27:08 +01:00
parent 1ed9360bc7
commit 36b581e3c1
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
2 changed files with 6 additions and 6 deletions

View File

@ -51,7 +51,7 @@ import org.moire.ultrasonic.util.FileUtil
import org.moire.ultrasonic.util.PermissionUtil import org.moire.ultrasonic.util.PermissionUtil
import org.moire.ultrasonic.util.ServerColor import org.moire.ultrasonic.util.ServerColor
import org.moire.ultrasonic.util.Settings import org.moire.ultrasonic.util.Settings
import org.moire.ultrasonic.util.SubsonicUncaughtExceptionHandler import org.moire.ultrasonic.util.UncaughtExceptionHandler
import org.moire.ultrasonic.util.Util import org.moire.ultrasonic.util.Util
import timber.log.Timber import timber.log.Timber
@ -380,8 +380,8 @@ class NavigationActivity : AppCompatActivity() {
private fun setUncaughtExceptionHandler() { private fun setUncaughtExceptionHandler() {
val handler = Thread.getDefaultUncaughtExceptionHandler() val handler = Thread.getDefaultUncaughtExceptionHandler()
if (handler !is SubsonicUncaughtExceptionHandler) { if (handler !is UncaughtExceptionHandler) {
Thread.setDefaultUncaughtExceptionHandler(SubsonicUncaughtExceptionHandler(this)) Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler(this))
} }
} }

View File

@ -9,7 +9,7 @@ import timber.log.Timber
/** /**
* Logs the stack trace of uncaught exceptions to a file on the SD card. * Logs the stack trace of uncaught exceptions to a file on the SD card.
*/ */
class SubsonicUncaughtExceptionHandler( class UncaughtExceptionHandler(
private val context: Context private val context: Context
) : Thread.UncaughtExceptionHandler { ) : Thread.UncaughtExceptionHandler {
private val defaultHandler: Thread.UncaughtExceptionHandler? = private val defaultHandler: Thread.UncaughtExceptionHandler? =
@ -31,8 +31,8 @@ class SubsonicUncaughtExceptionHandler(
throwable.printStackTrace(printWriter) throwable.printStackTrace(printWriter)
Timber.e(throwable, "Uncaught Exception! %s", logMessage) Timber.e(throwable, "Uncaught Exception! %s", logMessage)
Timber.i("Stack trace written to %s", file) Timber.i("Stack trace written to %s", file)
} catch (x: Throwable) { } catch (all: Throwable) {
Timber.e(x, "Failed to write stack trace to %s", file) Timber.e(all, "Failed to write stack trace to %s", file)
} finally { } finally {
Util.close(printWriter) Util.close(printWriter)
defaultHandler?.uncaughtException(thread, throwable) defaultHandler?.uncaughtException(thread, throwable)