Add LocalOnlyException
Some checks are pending
Build & Test / Validate (push) Waiting to run
Build & Test / Run Unit Tests (push) Blocked by required conditions
Build & Test / Run UI Tests (push) Blocked by required conditions
Build & Test / Validate (pull_request) Successful in 24s
Build & Test / Run Unit Tests (pull_request) Successful in 9m48s
Build & Test / Run UI Tests (pull_request) Successful in 9m48s
Some checks are pending
Build & Test / Validate (push) Waiting to run
Build & Test / Run Unit Tests (push) Blocked by required conditions
Build & Test / Run UI Tests (push) Blocked by required conditions
Build & Test / Validate (pull_request) Successful in 24s
Build & Test / Run Unit Tests (pull_request) Successful in 9m48s
Build & Test / Run UI Tests (pull_request) Successful in 9m48s
This is intended to enable local logging of some exceptions for debugging purposes without overrunning the remote crash reporter with issues that can't really be actioned upon
This commit is contained in:
parent
b42b949bdb
commit
01978548c6
2 changed files with 13 additions and 2 deletions
|
@ -5,6 +5,7 @@ import androidx.lifecycle.ViewModel
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.lifecycle.viewmodel.CreationExtras
|
||||
import com.wbrawner.simplemarkdown.core.LocalOnlyException
|
||||
import com.wbrawner.simplemarkdown.utility.FileHelper
|
||||
import com.wbrawner.simplemarkdown.utility.Preference
|
||||
import com.wbrawner.simplemarkdown.utility.PreferenceHelper
|
||||
|
@ -109,7 +110,7 @@ class MarkdownViewModel(
|
|||
preferenceHelper[Preference.AUTOSAVE_URI] = actualLoadPath
|
||||
} ?: throw IllegalStateException("Opened file was null")
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Failed to open file at path: $actualLoadPath")
|
||||
Timber.e(LocalOnlyException(e), "Failed to open file at path: $actualLoadPath")
|
||||
_state.value = _state.value.copy(
|
||||
alert = AlertDialogModel(
|
||||
text = ParameterizedText(R.string.file_load_error),
|
||||
|
|
|
@ -14,7 +14,9 @@ import timber.log.Timber
|
|||
class ErrorReporterTree private constructor(): Timber.Tree() {
|
||||
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
||||
if (priority != Log.ERROR) return
|
||||
t?.sendSilentlyWithAcra()
|
||||
if (t !is LocalOnlyException) {
|
||||
t?.sendSilentlyWithAcra()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -25,6 +27,14 @@ class ErrorReporterTree private constructor(): Timber.Tree() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An exception wrapper that prevents exceptions from being sent to an error reporter. Useful for
|
||||
* logging things like IOExceptions that are useful to see locally but not so helpful if reported
|
||||
*/
|
||||
class LocalOnlyException(override val message: String?, override val cause: Throwable): Exception(message, cause) {
|
||||
constructor(cause: Throwable): this(null, cause)
|
||||
}
|
||||
|
||||
private suspend fun Application.createErrorReporterTree() = withContext(Dispatchers.IO) {
|
||||
initAcra {
|
||||
reportFormat = StringFormat.JSON
|
||||
|
|
Loading…
Reference in a new issue