Skip to content

Commit

Permalink
Turn http error codes into exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Forsgren committed Apr 17, 2024
1 parent cb00d4d commit 92bcdad
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/attachmentclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ const attachmentclient = function attachmentclient(layer) {

// Do the actual call to server
const retval = fetch(url)
.then(res => res.json())
.then(res => {
if (!res.ok) {
throw new Error(`HTTP status ${res.status}`);
}
return res.json();
})
.then(res => {
const allAttachments = new Map();
if (res.attachmentInfos) {
Expand Down

0 comments on commit 92bcdad

Please sign in to comment.