summaryrefslogtreecommitdiffstats
path: root/src/renderer
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2018-12-08 14:43:23 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2018-12-08 14:43:23 +0100
commit33926af829848050c54c698ed22da9fe2b912aea (patch)
tree027a2965aa3da250bc665b3d7362a60d9a752bf7 /src/renderer
parent84caf3ba5baf6481b12112ae12a0f79a4f7a6e98 (diff)
downloadrpgedit-33926af829848050c54c698ed22da9fe2b912aea.tar
rpgedit-33926af829848050c54c698ed22da9fe2b912aea.zip
util: add fetch error handling
Diffstat (limited to 'src/renderer')
-rw-r--r--src/renderer/util.ts3
1 files changed, 3 insertions, 0 deletions
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<T extends any[]> {
export async function getJSON(url: string): Promise<any> {
const res = await window.fetch(url);
+ if (res.status < 200 || res.status >= 300)
+ throw new Error(res.statusText);
+
return await res.json();
}