diff --git a/src/lib/oa-rpde.js b/src/lib/oa-rpde.js index a42cfaf..7d6fe58 100644 --- a/src/lib/oa-rpde.js +++ b/src/lib/oa-rpde.js @@ -29,6 +29,9 @@ class OpenActiveRpde { try { log(`Fetching ${nextURL}`); let res = await fetch(nextURL); + if (!res.ok) { + throw res.status + " - " + res.statusText; + } let activitiesJson = await res.json(); diff --git a/src/lib/stage-both.js b/src/lib/stage-both.js index 5934543..1db8c87 100644 --- a/src/lib/stage-both.js +++ b/src/lib/stage-both.js @@ -19,6 +19,10 @@ async function processBothStages() { await Utils.loadActivitiesJSONIntoCache(); let res = await fetch(Settings.registryURL); + if (!res.ok) { + throw res.status + " - " + res.statusText; + } + let registryJson = await res.json(); for (const publisherKey in registryJson.data) { diff --git a/src/lib/stage1.js b/src/lib/stage1.js index 05fa31e..a5fde28 100644 --- a/src/lib/stage1.js +++ b/src/lib/stage1.js @@ -18,6 +18,9 @@ async function processStage1() { } let res = await fetch(Settings.registryURL); + if (!res.ok) { + throw res.status + " - " + res.statusText; + } let registryJson = await res.json(); for (const publisherKey in registryJson.data) { diff --git a/src/lib/stage2.js b/src/lib/stage2.js index 435818d..f0d7a09 100644 --- a/src/lib/stage2.js +++ b/src/lib/stage2.js @@ -20,6 +20,9 @@ async function processStage2() { await Utils.loadActivitiesJSONIntoCache(); let res = await fetch(Settings.registryURL); + if (!res.ok) { + throw res.status + " - " + res.statusText; + } let registryJson = await res.json(); for (const publisherKey in registryJson.data) { diff --git a/src/lib/utils.js b/src/lib/utils.js index 20435c5..5d00160 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -51,7 +51,9 @@ class Utils { const res = await fetch(Settings.activityListJSONLD); - // TODO detect non 200 responses + if (!res.ok) { + throw res.status + " - " + res.statusText; + } const activitiesData = await res.json();