0d117c106a
* Fix 404 and 410 API errors being silently discarded in WebUI Fixes #13278 * Return more appropriate error when user replies to a deleted toot * Please CodeClimate * Fix 404/410 errors on fetching account timelines & identity proofs * Refactor error handling * Move error message string to statuses.errors
18 lines
450 B
JavaScript
18 lines
450 B
JavaScript
import { showAlertForError } from '../actions/alerts';
|
|
|
|
const defaultFailSuffix = 'FAIL';
|
|
|
|
export default function errorsMiddleware() {
|
|
return ({ dispatch }) => next => action => {
|
|
if (action.type && !action.skipAlert) {
|
|
const isFail = new RegExp(`${defaultFailSuffix}$`, 'g');
|
|
|
|
if (action.type.match(isFail)) {
|
|
dispatch(showAlertForError(action.error, action.skipNotFound));
|
|
}
|
|
}
|
|
|
|
return next(action);
|
|
};
|
|
};
|