From 524428b94330bf0100fc4ea6452a6057edfd3636 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 31 Dec 2022 12:24:05 -0800 Subject: fix error handler --- src/lib/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lib/utils.js') diff --git a/src/lib/utils.js b/src/lib/utils.js index e5441575..eb0d27de 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -48,10 +48,10 @@ export const post = (url, body, headers) => { try { let { message } = JSON.parse(text); - if (message) return JSON.stringify({ name: 'Error', message }); + if (message) throw new Error(message); } catch (e) {} - return { error: text }; + throw new Error(text); }) .then((body) => { try { @@ -60,7 +60,7 @@ export const post = (url, body, headers) => { throw new Error(body); } - if (body.error) throw body.error; + if (body.error instanceof Error) throw body.error; if (body instanceof Error) throw body; if (body.name === 'Error') throw new Error(body.message); -- cgit v1.2.3