From f215026f8b8645b8f476d555cfc713a36ec972ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Fri, 17 Jul 2015 16:12:24 +0200 Subject: [PATCH] better error messages for API failures --- js/components/global_notification.js | 5 +++++ js/utils/requests.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/js/components/global_notification.js b/js/components/global_notification.js index aefe525a..59663b28 100644 --- a/js/components/global_notification.js +++ b/js/components/global_notification.js @@ -53,6 +53,11 @@ let GlobalNotification = React.createClass({ onChange(state) { let notification = this.extractFirstElem(state.notificationQue); + // error handling for notifications + if(notification.message && notification.type === 'danger') { + console.logGlobal(new Error(notification.message.message)); + } + if(notification.show) { this.setState(notification); } else { diff --git a/js/utils/requests.js b/js/utils/requests.js index 4341adde..ea923576 100644 --- a/js/utils/requests.js +++ b/js/utils/requests.js @@ -19,9 +19,9 @@ class Requests { unpackResponse(response) { if (response.status >= 500) { - console.logGlobal(new Error(response.status + ': Generic server error - ' + response.statusText)); + console.logGlobal(new Error(response.status + ' - ' + response.statusText + ' - on URL:' + response.url)); } else if(response.status >= 400 && response.status < 500) { - console.logGlobal(new Error(response.status + ': Generic request error - ' + response.statusText)); + console.logGlobal(new Error(response.status + ' - ' + response.statusText + ' - on URL:' + response.url)); } return response.text(); }