From a963ea67dda17f69ed783b3fbcc91e5ce3858ad3 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sun, 10 Feb 2019 21:28:29 +0100 Subject: [Glitch] Add missing rejection handling for Promises Port missing parts from 2c51bc0ca5a4c3a4bb140b4b40dabdda859ebb94 to glitch-soc --- app/javascript/flavours/glitch/middleware/errors.js | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'app/javascript/flavours/glitch/middleware') diff --git a/app/javascript/flavours/glitch/middleware/errors.js b/app/javascript/flavours/glitch/middleware/errors.js index f3dfc8b06..212c1f4ad 100644 --- a/app/javascript/flavours/glitch/middleware/errors.js +++ b/app/javascript/flavours/glitch/middleware/errors.js @@ -1,4 +1,4 @@ -import { showAlert } from 'flavours/glitch/actions/alerts'; +import { showAlertForError } from 'flavours/glitch/actions/alerts'; const defaultFailSuffix = 'FAIL'; @@ -8,21 +8,7 @@ export default function errorsMiddleware() { const isFail = new RegExp(`${defaultFailSuffix}$`, 'g'); if (action.type.match(isFail)) { - if (action.error.response) { - const { data, status, statusText } = action.error.response; - - let message = statusText; - let title = `${status}`; - - if (data.error) { - message = data.error; - } - - dispatch(showAlert(title, message)); - } else { - console.error(action.error); - dispatch(showAlert('Oops!', 'An unexpected error occurred.')); - } + dispatch(showAlertForError(action.error)); } } -- cgit