From 896275c9fadd660fe26be772d98219cd8a899010 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 3 Aug 2026 14:06:40 -0700 Subject: [PATCH] Wrap RPC call to catch network errors. --- src/lib/block/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/block/index.ts b/src/lib/block/index.ts index 07c6c4a..a214faf 100644 --- a/src/lib/block/index.ts +++ b/src/lib/block/index.ts @@ -209,11 +209,15 @@ export class Block { json_block: true, block: this.toJSON() } - const res = await rpc.post('process', data) - if (res == null || typeof res !== 'object' || !('hash' in res) || typeof res.hash !== 'string') { - throw new Error('Block could not be processed', { cause: res }) + try { + const res = await rpc.post('process', data) + if (res == null || typeof res !== 'object' || !('hash' in res) || typeof res.hash !== 'string') { + throw new Error('RPC process request received incomplete response', { cause: res }) + } + return res.hash + } catch (err) { + throw new Error('Block could not be processed', { cause: err }) } - return res.hash } /** -- 2.52.0