aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-12-31 12:24:05 -0800
committerAdam Soltys <[email protected]>2022-12-31 12:24:05 -0800
commit524428b94330bf0100fc4ea6452a6057edfd3636 (patch)
tree782a6fbdaa9107226cdbed93de34351308c9e887
parent97c0bf2a15a6570093b326044766d127ba950347 (diff)
downloadcoinos-ui-524428b94330bf0100fc4ea6452a6057edfd3636.tar.gz
coinos-ui-524428b94330bf0100fc4ea6452a6057edfd3636.zip
fix error handler
-rw-r--r--src/lib/utils.js6
1 files changed, 3 insertions, 3 deletions
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);