1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00

PR Feedback: Change API error handling to saver approach

This commit is contained in:
Tim Daubenschütz 2015-09-30 11:22:20 +02:00
parent 40095f7fbf
commit 7283ae7574
2 changed files with 6 additions and 1 deletions

View File

@ -33,6 +33,10 @@ class EditionListActions {
EditionListFetcher EditionListFetcher
.fetch(pieceId, page, pageSize, orderBy, orderAsc, filterBy) .fetch(pieceId, page, pageSize, orderBy, orderAsc, filterBy)
.then((res) => { .then((res) => {
if(res && !res.editions) {
throw new Error('Piece has no editions to fetch.');
}
this.actions.updateEditionList({ this.actions.updateEditionList({
pieceId, pieceId,
page, page,
@ -46,6 +50,7 @@ class EditionListActions {
resolve(res); resolve(res);
}) })
.catch((err) => { .catch((err) => {
console.logGlobal(err);
reject(err); reject(err);
}); });
}); });

View File

@ -21,7 +21,7 @@ class Requests {
} }
unpackResponse(response) { unpackResponse(response) {
if (response.status >= 400) { if (response.status >= 500) {
throw new Error(response.status + ' - ' + response.statusText + ' - on URL:' + response.url); throw new Error(response.status + ' - ' + response.statusText + ' - on URL:' + response.url);
} }