diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2018-12-08 14:43:23 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2018-12-08 14:43:23 +0100 |
commit | 33926af829848050c54c698ed22da9fe2b912aea (patch) | |
tree | 027a2965aa3da250bc665b3d7362a60d9a752bf7 | |
parent | 84caf3ba5baf6481b12112ae12a0f79a4f7a6e98 (diff) | |
download | rpgedit-33926af829848050c54c698ed22da9fe2b912aea.tar rpgedit-33926af829848050c54c698ed22da9fe2b912aea.zip |
util: add fetch error handling
-rw-r--r-- | src/renderer/util.ts | 3 |
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(); } |