Skip to content

Commit

Permalink
feat(sagas): toast API errors
Browse files Browse the repository at this point in the history
Closes #10. Depends on kleros/kleros-api-DEPRECATED#107
  • Loading branch information
brainsolution committed Mar 22, 2018
1 parent 8e01ff5 commit 8d5eaec
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/sagas/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { delay } from 'redux-saga'
import { toastr } from 'react-redux-toastr'

import { spawn, call, all } from 'redux-saga/effects'

Expand Down Expand Up @@ -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)
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/utils/saga.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { toastr } from 'react-redux-toastr'

import { call, put } from 'redux-saga/effects'

import { action as _action, errorAction } from './action'
Expand All @@ -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))
}
}
Expand All @@ -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))
}
}
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 8d5eaec

Please sign in to comment.