aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils.js
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
commite778249286da91802559c1b1984be978bb185bb4 (patch)
tree782a6fbdaa9107226cdbed93de34351308c9e887 /src/lib/utils.js
parent0f7b6e9dc62c3350f4906bbae21b92732c282983 (diff)
downloadcoinos-ui-e778249286da91802559c1b1984be978bb185bb4.tar.gz
coinos-ui-e778249286da91802559c1b1984be978bb185bb4.zip
fix error handler
Diffstat (limited to 'src/lib/utils.js')
-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);