Skip to content

Commit ba78f78

Browse files
fix(crash): Send actual exception string in crash report
This commit modifies the crash reporting mechanism to send the actual exception string as part of the crash report payload. Previously, the stack trace was read from a log file, which could be unavailable. Now, the `Throwable` exception is converted to a string in `CrashHandler` and passed via an `Intent` extra to `CrashReportActivity`. This ensures the stack trace is reliably included in the JSON payload sent to the remote endpoint, replacing the previous "No stack trace available" placeholder.
1 parent 919f63f commit ba78f78

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

app/src/main/java/com/github/droidworksstudio/common/CrashHandler.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class CrashHandler(private val context: Context) : Thread.UncaughtExceptionHandl
156156
val intent = Intent(context, CrashReportActivity::class.java).apply {
157157
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
158158
putExtra("crash_log_uri", uri.toString())
159+
putExtra("exception", exception.toString())
159160
}
160161
context.startActivity(intent)
161162
} catch (_: Exception) {

app/src/main/java/com/github/droidworksstudio/mlauncher/CrashReportActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@ class CrashReportActivity : AppCompatActivity() {
9090
Base64.encodeToString(it, Base64.NO_WRAP)
9191
} ?: ""
9292

93+
val exception: String = intent.getStringExtra("exception").toString()
94+
9395
// Build crash JSON
9496
val crashJson = JSONObject().apply {
9597
put("thread", "main")
9698
put("message", "App crashed")
97-
put("stackTrace", logContent ?: "No stack trace available")
9899
put("device", JSONObject(deviceMap))
99100
put("timestamp", System.currentTimeMillis())
100101
put("logFileBase64", logBase64)
102+
put("stackTrace", exception)
101103
}.toString()
102104

103105
val url = URL("https://crash-worker.wayne6324.workers.dev")

0 commit comments

Comments
 (0)