24 lines
626 B
Kotlin
24 lines
626 B
Kotlin
@file:Suppress("ktlint:filename")
|
|
|
|
package co.electriccoin.zcash.crash
|
|
|
|
import co.electriccoin.zcash.spackle.io.writeAtomically
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.withContext
|
|
import java.io.File
|
|
|
|
suspend fun ReportableException.write(path: File) {
|
|
val exceptionString = buildString {
|
|
appendLine("App version: $appVersion")
|
|
appendLine("Is uncaught: $isUncaught")
|
|
appendLine("Time: $time")
|
|
append(exceptionTrace)
|
|
}
|
|
|
|
withContext(Dispatchers.IO) {
|
|
path.writeAtomically { tempFile ->
|
|
tempFile.writeText(exceptionString)
|
|
}
|
|
}
|
|
}
|