Throw ConnectionError instead of swallowing error

This commit is contained in:
RMidhunSuresh 2022-08-10 22:23:51 +05:30
parent c898bcb46a
commit ff706e542d

View file

@ -119,10 +119,10 @@ export function createFetchRequest(createTimeout, serviceWorkerHandler) {
body = await response.text(); body = await response.text();
} }
} catch (err) { } catch (err) {
// some error pages return html instead of json, ignore error if (err.name === "SyntaxError" && status >= 400) {
if (!(err.name === "SyntaxError" && status >= 400)) { throw new ConnectionError(`${method} ${url}: Failed to fetch JSON file!`);
throw err;
} }
throw err;
} }
return {status, body}; return {status, body};
}, err => { }, err => {