Adds logging when a crash occurs

blinds
Laurent 5 years ago
parent eb86679fa7
commit 5f675d9f67
  1. 2
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/ComputedAction.kt
  2. 25
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/EditorViewModel.kt

@ -290,4 +290,6 @@ class ComputedAction(var manager: ActionManager,
override val positionIndex: Int
get() { return this.action.position }
val logRepresentation: String = "${this.action.type}, ${this.position}, ${this.action.amount}"
}

@ -26,9 +26,11 @@ import net.pokeranalytics.android.ui.modules.handhistory.views.CardCentralizer
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
import net.pokeranalytics.android.ui.view.rows.CustomizableRowRepresentable
import net.pokeranalytics.android.util.CrashLogging
import net.pokeranalytics.android.util.extensions.findById
import net.pokeranalytics.android.util.extensions.formatted
import timber.log.Timber
import java.lang.Exception
import java.text.DecimalFormat
import java.text.ParseException
import kotlin.coroutines.CoroutineContext
@ -543,17 +545,24 @@ class EditorViewModel : ViewModel(), RowRepresentableDataSource, CardCentralizer
return
}
when (val row = this.rowRepresentables[this.currentSelection.index]) {
is ComputedAction -> {
this.sortedActions.setAmount(this.actionIndexForSelection, amount)
}
is PlayerSetupRow -> {
row.setStack(amount)
this.sortedActions.updateRemainingStacksForPositions(listOf(row.positionIndex))
try { // can crash in setAmount for example
when (val row = this.rowRepresentables[this.currentSelection.index]) {
is ComputedAction -> {
this.sortedActions.setAmount(this.actionIndexForSelection, amount)
}
is PlayerSetupRow -> {
row.setStack(amount)
this.sortedActions.updateRemainingStacksForPositions(listOf(row.positionIndex))
}
else -> {}
}
else -> {}
} catch (e: Exception) {
val actions = this.sortedActions.joinToString("\n") { it.logRepresentation }
CrashLogging.log(actions)
throw e
}
this.currentAmount = null
}

Loading…
Cancel
Save