diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-04-06 18:55:25 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-04-06 18:55:58 +0200 |
commit | d4d20533556928f63c8759437f67e76336bab55e (patch) | |
tree | 34e7bb151b5d21497665131b6ab8d875254e7666 /sw-ui/src/sagas/errors.ts | |
parent | Refactoring in GameScene.kt (diff) | |
download | seven-wonders-d4d20533556928f63c8759437f67e76336bab55e.tar.gz seven-wonders-d4d20533556928f63c8759437f67e76336bab55e.tar.bz2 seven-wonders-d4d20533556928f63c8759437f67e76336bab55e.zip |
Delete old React/TypeScript UI
Diffstat (limited to 'sw-ui/src/sagas/errors.ts')
-rw-r--r-- | sw-ui/src/sagas/errors.ts | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/sw-ui/src/sagas/errors.ts b/sw-ui/src/sagas/errors.ts deleted file mode 100644 index b27dfa95..00000000 --- a/sw-ui/src/sagas/errors.ts +++ /dev/null @@ -1,36 +0,0 @@ -import {Toaster} from '@blueprintjs/core'; -import {Channel, eventChannel} from 'redux-saga'; -import {apply, cancelled, take} from 'redux-saga/effects'; -import {ApiError} from '../api/model'; -import {SevenWondersSession} from '../api/sevenWondersApi'; - -const ErrorToaster = Toaster.create(); - -export function* errorHandlingSaga(session: SevenWondersSession): any { - const errorChannel: Channel<ApiError> = yield eventChannel(session.watchErrors()); - try { - while (true) { - const error: ApiError = yield take(errorChannel); - yield* handleOneError(error); - } - } finally { - if (yield cancelled()) { - console.log('Error management saga cancelled'); - yield apply(errorChannel, errorChannel.close); - } - } -} - -function* handleOneError(err: ApiError): any { - console.error('Error received on web socket channel', err); - const msg = buildMsg(err); - yield apply(ErrorToaster, ErrorToaster.show, [{ intent: 'danger', icon: 'error', message: msg }]); -} - -function buildMsg(err: ApiError): string { - if (err.details.length > 0) { - return err.details.map(d => d.message).join('\n'); - } else { - return err.message; - } -} |