Skip to content
Snippets Groups Projects
Verified Commit 91b3a7d2 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Don't treat a 404 as a fatal error

parent d09f806a
Branches
Tags v1.0.21
No related merge requests found
...@@ -19,18 +19,26 @@ class FanartApi { ...@@ -19,18 +19,26 @@ class FanartApi {
timeout: 2000, timeout: 2000,
}, },
}).then((response) => { }).then((response) => {
if (response.status === 404) {
return null;
} else {
return response.text().then(text => { return response.text().then(text => {
return { return {
ok: response.ok, ok: response.ok,
body: text, body: text,
} }
}); });
}
}).then((data) => { }).then((data) => {
if (data === null) {
return null;
} else {
const {ok, body} = data; const {ok, body} = data;
if (!ok) { if (!ok) {
throw new Error(`${url}: ${body}`); throw new Error(`${url}: ${body}`);
} }
return JSON.parse(body); return JSON.parse(body);
}
}).catch(err => { }).catch(err => {
console.error(err); console.error(err);
return null; return null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment