summaryrefslogtreecommitdiff
path: root/frontend/src/sagas/errors.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/sagas/errors.js')
-rw-r--r--frontend/src/sagas/errors.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/frontend/src/sagas/errors.js b/frontend/src/sagas/errors.js
new file mode 100644
index 00000000..6d4df93d
--- /dev/null
+++ b/frontend/src/sagas/errors.js
@@ -0,0 +1,23 @@
+import { apply, call, cancelled, put, take } from 'redux-saga/effects'
+
+import { createSubscriptionChannel } from '../utils/websocket'
+import { actions } from '../redux/errors'
+
+export default function *errorHandlingSaga({ socket }) {
+ const errorChannel = yield call(createSubscriptionChannel, socket, '/user/queue/error')
+ try {
+ while (true) {
+ const error = yield take(errorChannel)
+ yield* handleOneError(error)
+ }
+ } finally {
+ if (yield cancelled()) {
+ yield apply(errorChannel, errorChannel.close)
+ }
+ }
+}
+
+function *handleOneError(error) {
+ console.error("Error received on web socket channel", error)
+ yield put(actions.errorReceived(error))
+}
bgstack15