From 92bcdada5bb6282a91e0533b5b66d2c56a820c8d Mon Sep 17 00:00:00 2001 From: Stefan Forsgren Date: Wed, 17 Apr 2024 14:02:28 +0200 Subject: [PATCH] Turn http error codes into exceptions --- src/utils/attachmentclient.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/attachmentclient.js b/src/utils/attachmentclient.js index f43bb530a..cab744393 100644 --- a/src/utils/attachmentclient.js +++ b/src/utils/attachmentclient.js @@ -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) {