Skip to content

Commit 4f848b8

Browse files
committed
Merge pull request #5538 from grzesiek2010/castException
Catch ClassCastException and log it with more details
1 parent 15b2688 commit 4f848b8

File tree

1 file changed

+6
-2
lines changed
  • androidshared/src/main/java/org/odk/collect/androidshared/data

1 file changed

+6
-2
lines changed

androidshared/src/main/java/org/odk/collect/androidshared/data/AppState.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ interface StateStore {
6262
}
6363

6464
fun Application.getState(): AppState {
65-
val stateStore = this as StateStore
66-
return stateStore.getState()
65+
try {
66+
val stateStore = this as StateStore
67+
return stateStore.getState()
68+
} catch (e: ClassCastException) {
69+
throw ClassCastException("${this.javaClass} cannot be cast to StateStore")
70+
}
6771
}
6872

6973
fun Context.getState(): AppState {

0 commit comments

Comments
 (0)