diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-03-27 01:42:52 +0100 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-03-27 10:59:39 +0100 |
commit | 333c12312ce19595e21da5edd87f99f32c5c57e1 (patch) | |
tree | 38b37f85ce14292333362296716fc6564179e8b8 /sw-ui-kt/src/main/kotlin | |
parent | Add missing prepareMove method in SwClient (diff) | |
download | seven-wonders-333c12312ce19595e21da5edd87f99f32c5c57e1.tar.gz seven-wonders-333c12312ce19595e21da5edd87f99f32c5c57e1.tar.bz2 seven-wonders-333c12312ce19595e21da5edd87f99f32c5c57e1.zip |
Add error handling saga printing errors in console
Diffstat (limited to 'sw-ui-kt/src/main/kotlin')
-rw-r--r-- | sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt b/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt index a0cd6f3c..2a501566 100644 --- a/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt +++ b/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt @@ -1,6 +1,7 @@ package org.luxons.sevenwonders.ui.redux.sagas import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch import org.luxons.sevenwonders.client.SevenWondersClient import org.luxons.sevenwonders.client.SevenWondersSession import org.luxons.sevenwonders.ui.redux.RequestChooseName @@ -18,6 +19,10 @@ suspend fun SwSagaContext.rootSaga() = coroutineScope { val session = SevenWondersClient().connect("localhost:8000") console.info("Connected to Seven Wonders web socket API") + launch { + errorSaga(session) + } + val player = session.chooseName(action.playerName) dispatch(SetCurrentPlayerAction(player)) @@ -31,9 +36,17 @@ suspend fun SwSagaContext.rootSaga() = coroutineScope { } } -private suspend fun SwSagaContext.homeSaga(session: SevenWondersSession): SevenWondersSession { +private suspend fun errorSaga(session: SevenWondersSession) { + val errorsSub = session.watchErrors() + for (err in errorsSub.messages) { + // TODO use blueprintjs toaster + console.error("${err.code}: ${err.message}") + console.error(JSON.stringify(err)) + } +} + +private suspend fun SwSagaContext.homeSaga(session: SevenWondersSession) { val action = next<RequestChooseName>() val player = session.chooseName(action.playerName) dispatch(SetCurrentPlayerAction(player)) - return session } |