From fbd8fa87aeb8b853a743606bf97e3a0f65dd6ce6 Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 28 Mar 2022 10:36:43 -0400 Subject: [PATCH] Improve error handling --- app/soapbox/actions/alerts.js | 11 +++++++---- app/soapbox/components/modal_root.js | 2 +- app/styles/components/snackbar.scss | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/soapbox/actions/alerts.js b/app/soapbox/actions/alerts.js index d1ba11fdb..cb8be15b4 100644 --- a/app/soapbox/actions/alerts.js +++ b/app/soapbox/actions/alerts.js @@ -34,7 +34,7 @@ export function showAlert(title = messages.unexpectedTitle, message = messages.u } export function showAlertForError(error) { - return (dispatch, getState) => { + return (dispatch, _getState) => { if (error.response) { const { data, status, statusText } = error.response; @@ -47,14 +47,17 @@ export function showAlertForError(error) { return dispatch(noOp); } - let message = statusText; - const title = `${status}`; + if (status === 413) { + return dispatch(showAlert('', 'File exceeds the file size limit', 'error')); + } + + let message = statusText || status; if (data.error) { message = data.error; } - return dispatch(showAlert(title, message, 'error')); + return dispatch(showAlert('', message, 'error')); } else { console.error(error); return dispatch(showAlert(undefined, undefined, 'error')); diff --git a/app/soapbox/components/modal_root.js b/app/soapbox/components/modal_root.js index feefbf6d6..628d02fa4 100644 --- a/app/soapbox/components/modal_root.js +++ b/app/soapbox/components/modal_root.js @@ -203,7 +203,7 @@ class ModalRoot extends React.PureComponent {