Skip to content

Commit

Permalink
Merge pull request #5538 from grzesiek2010/castException
Browse files Browse the repository at this point in the history
Catch ClassCastException and log it with more details
  • Loading branch information
seadowg committed Apr 4, 2023
1 parent 15b2688 commit 4f848b8
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ interface StateStore {
}

fun Application.getState(): AppState {
val stateStore = this as StateStore
return stateStore.getState()
try {
val stateStore = this as StateStore
return stateStore.getState()
} catch (e: ClassCastException) {
throw ClassCastException("${this.javaClass} cannot be cast to StateStore")
}
}

fun Context.getState(): AppState {
Expand Down

0 comments on commit 4f848b8

Please sign in to comment.