feat(error-handler): add error handler middleware POC
This commit is contained in:
parent
ed4ffd92a9
commit
1fcb29f6d2
|
@ -0,0 +1,22 @@
|
|||
// @flow
|
||||
import { LOAD_ADDRESSES_ERROR } from './modules/receive';
|
||||
import { VALIDATE_ADDRESS_ERROR } from './modules/send';
|
||||
import { LOAD_TRANSACTIONS_ERROR } from './modules/transactions';
|
||||
import { LOAD_WALLET_SUMMARY_ERROR } from './modules/wallet';
|
||||
import { showErrorModal } from './modules/app';
|
||||
|
||||
import type { Middleware } from '../types/redux';
|
||||
|
||||
const ERRORS = [
|
||||
LOAD_ADDRESSES_ERROR,
|
||||
VALIDATE_ADDRESS_ERROR,
|
||||
LOAD_TRANSACTIONS_ERROR,
|
||||
LOAD_WALLET_SUMMARY_ERROR,
|
||||
];
|
||||
|
||||
export const errorHandler: Middleware = ({ dispatch }) => next => (action) => {
|
||||
// eslint-disable-next-line max-len
|
||||
if (ERRORS.includes(action.type)) return dispatch(showErrorModal({ error: action.payload.error || 'Something went wrong!' }));
|
||||
|
||||
return next(action);
|
||||
};
|
Loading…
Reference in New Issue