From 111a07e654786c6ac31f12375898819fdb0c1672 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Wed, 20 Aug 2025 11:51:54 -0700 Subject: [PATCH] Process RPC response body prior to checking for errors so any error messages can be handled. --- src/lib/rpc.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/rpc.ts b/src/lib/rpc.ts index a2bec84..885f42f 100644 --- a/src/lib/rpc.ts +++ b/src/lib/rpc.ts @@ -55,10 +55,10 @@ export class Rpc { }, 10000) try { const res = await fetch(req) + const data = await res.json() if (res.status !== 200) { - throw new Error(`${res.status} ${res.statusText}`) + throw new Error(`${res.status} ${res.statusText}`, { cause: data }) } - const data = await res.json() if (data.error != null) { const msg = data.message == null ? data.error @@ -67,6 +67,7 @@ export class Rpc { } return data } catch (err) { + console.error(err) return JSON.stringify(err) } finally { clearTimeout(kill) -- 2.47.3