From: Chris Duncan Date: Wed, 20 Aug 2025 18:51:54 +0000 (-0700) Subject: Process RPC response body prior to checking for errors so any error messages can... X-Git-Tag: v0.10.5~41^2~39 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=111a07e654786c6ac31f12375898819fdb0c1672;p=libnemo.git Process RPC response body prior to checking for errors so any error messages can be handled. --- 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)