Skip to content

Commit

Permalink
feat: special UE handler
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelonion committed Apr 30, 2024
1 parent 4fc96b7 commit 69fb86d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/src/main/java/ani/dantotsu/util/Logger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ object Logger {
}
}

fun uncaughtException(t: Thread, e: Throwable) {
loggerExecutor.execute {
if (file == null) e.printStackTrace() else {
file?.appendText("---------------------------Uncaught Exception---------------------------\n")
file?.appendText("thread: ${t.name}\n")
file?.appendText("date/time: ${Date()} | ${e.message}\n")
file?.appendText("trace: ${e.stackTraceToString()}\n")
}
}
}

fun shareLog(context: Context) {
if (file == null) {
snackString("No log file found")
Expand Down Expand Up @@ -151,7 +162,7 @@ class FinalExceptionHandler : Thread.UncaughtExceptionHandler {
Thread.getDefaultUncaughtExceptionHandler()

override fun uncaughtException(t: Thread, e: Throwable) {
Logger.log(e)
Logger.uncaughtException(t, e)
Injekt.get<CrashlyticsInterface>().logException(e)
defaultUEH?.uncaughtException(t, e)
}
Expand Down

0 comments on commit 69fb86d

Please sign in to comment.