From 8d5eaec1267c333f61af5f9eb9acd5722fe58370 Mon Sep 17 00:00:00 2001 From: brainsolution Date: Wed, 21 Mar 2018 20:17:12 -0700 Subject: [PATCH] feat(sagas): toast API errors Closes #10. Depends on kleros/kleros-api#107 --- package.json | 2 +- src/sagas/index.js | 3 +++ src/utils/saga.js | 4 ++++ yarn.lock | 6 +++--- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 4b321e6..424b296 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "ganache-cli": "^6.1.0", "husky": "^0.14.3", "jest-enzyme": "^4.0.2", - "kleros-scripts": "^0.4.0", + "kleros-scripts": "^0.5.0", "node-sass-chokidar": "^0.0.3", "npm-run-all": "^4.1.2", "prop-types": "^15.6.0", diff --git a/src/sagas/index.js b/src/sagas/index.js index 6b6a00a..bb07957 100644 --- a/src/sagas/index.js +++ b/src/sagas/index.js @@ -1,4 +1,5 @@ import { delay } from 'redux-saga' +import { toastr } from 'react-redux-toastr' import { spawn, call, all } from 'redux-saga/effects' @@ -28,6 +29,8 @@ export function makeRestartable(saga) { 'Saga error, the saga will be restarted after 3 seconds.', err ) + + toastr.error('', err.message.slice(0, 100)) yield call(delay, 3000) } } diff --git a/src/utils/saga.js b/src/utils/saga.js index 02d1bb9..4cbb59f 100644 --- a/src/utils/saga.js +++ b/src/utils/saga.js @@ -1,3 +1,5 @@ +import { toastr } from 'react-redux-toastr' + import { call, put } from 'redux-saga/effects' import { action as _action, errorAction } from './action' @@ -18,6 +20,7 @@ export function* fetchSaga(resourceActions, saga, action) { }) ) } catch (err) { + toastr.error('', err.message.slice(0, 100)) yield put(errorAction(resourceActions.FAIL_FETCH, err)) } } @@ -40,6 +43,7 @@ export function* updateSaga(resourceActions, saga, action) { }) ) } catch (err) { + toastr.error('', err.message.slice(0, 100)) yield put(errorAction(resourceActions.FAIL_UPDATE, err)) } } diff --git a/yarn.lock b/yarn.lock index 37ac535..1c10937 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7292,9 +7292,9 @@ kleros-interaction@^0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/kleros-interaction/-/kleros-interaction-0.0.8.tgz#84e6db47126b9782687ea332e4cee5120d2efa50" -kleros-scripts@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/kleros-scripts/-/kleros-scripts-0.4.0.tgz#2ea8849e8673e9e64ed7c3364107d81bc9da384b" +kleros-scripts@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/kleros-scripts/-/kleros-scripts-0.5.0.tgz#df9c0729c698552ea10c0be58c393379c819fb6d" dependencies: "@commitlint/cli" "^6.1.0" "@commitlint/config-conventional" "^6.1.0"