mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +01:00
PR Feedback: Change API error handling to saver approach
This commit is contained in:
parent
40095f7fbf
commit
7283ae7574
@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user