From 7283ae7574ce94cd5c1c904e1226c86a46656c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Wed, 30 Sep 2015 11:22:20 +0200 Subject: [PATCH] PR Feedback: Change API error handling to saver approach --- js/actions/edition_list_actions.js | 5 +++++ js/utils/requests.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/js/actions/edition_list_actions.js b/js/actions/edition_list_actions.js index d13882cd..fb0a2249 100644 --- a/js/actions/edition_list_actions.js +++ b/js/actions/edition_list_actions.js @@ -33,6 +33,10 @@ class EditionListActions { EditionListFetcher .fetch(pieceId, page, pageSize, orderBy, orderAsc, filterBy) .then((res) => { + if(res && !res.editions) { + throw new Error('Piece has no editions to fetch.'); + } + this.actions.updateEditionList({ pieceId, page, @@ -46,6 +50,7 @@ class EditionListActions { resolve(res); }) .catch((err) => { + console.logGlobal(err); reject(err); }); }); diff --git a/js/utils/requests.js b/js/utils/requests.js index 3761a7a0..fd676896 100644 --- a/js/utils/requests.js +++ b/js/utils/requests.js @@ -21,7 +21,7 @@ class Requests { } unpackResponse(response) { - if (response.status >= 400) { + if (response.status >= 500) { throw new Error(response.status + ' - ' + response.statusText + ' - on URL:' + response.url); }