about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/middleware/errors.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-02-10 21:28:29 +0100
committerThibaut Girka <thib@sitedethib.com>2019-02-10 21:44:14 +0100
commita963ea67dda17f69ed783b3fbcc91e5ce3858ad3 (patch)
tree86989e490ae6b7ed7460a4cb2345a48d56e5efcd /app/javascript/flavours/glitch/middleware/errors.js
parent6b2eefc7bf8cf1bb58da165d9594d9b17bf97e11 (diff)
[Glitch] Add missing rejection handling for Promises
Port missing parts from 2c51bc0ca5a4c3a4bb140b4b40dabdda859ebb94 to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/middleware/errors.js')
-rw-r--r--app/javascript/flavours/glitch/middleware/errors.js18
1 files changed, 2 insertions, 16 deletions
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));
       }
     }