From 665d573610a0d37bb1b7f1bc614ae39f1ceb5d63 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Sat, 16 Mar 2024 14:58:27 +0900 Subject: [PATCH] Fix error handling in fetchNative function --- src/ts/storage/globalApi.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ts/storage/globalApi.ts b/src/ts/storage/globalApi.ts index 2351a7a6..b6deb6be 100644 --- a/src/ts/storage/globalApi.ts +++ b/src/ts/storage/globalApi.ts @@ -1370,9 +1370,14 @@ export async function fetchNative(url:string, arg:{ headers: JSON.stringify(headers), body: arg.body, }).then((res) => { - const parsedRes = JSON.parse(res as string) - if(!parsedRes.success){ - error = parsedRes.body + try { + const parsedRes = JSON.parse(res as string) + if(!parsedRes.success){ + error = parsedRes.body + resolved = true + } + } catch (error) { + error = JSON.stringify(error) resolved = true } })