From 33926af829848050c54c698ed22da9fe2b912aea Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 8 Dec 2018 14:43:23 +0100 Subject: util: add fetch error handling --- src/renderer/util.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/renderer/util.ts b/src/renderer/util.ts index 4fedbd5..5ea0c88 100644 --- a/src/renderer/util.ts +++ b/src/renderer/util.ts @@ -48,6 +48,9 @@ export class Listenable { export async function getJSON(url: string): Promise { const res = await window.fetch(url); + if (res.status < 200 || res.status >= 300) + throw new Error(res.statusText); + return await res.json(); } -- cgit v1.2.3