From eaacebeeccf424b25afc67592d04b2aa3db38b19 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 2 Jan 2026 12:20:48 +0100 Subject: [PATCH] fix: improve onboarding/imessage errors --- src/commands/onboard-helpers.ts | 10 +++++++++- src/commands/onboard-providers.ts | 2 +- src/imessage/client.ts | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/commands/onboard-helpers.ts b/src/commands/onboard-helpers.ts index 258ff1575..024be2646 100644 --- a/src/commands/onboard-helpers.ts +++ b/src/commands/onboard-helpers.ts @@ -1,6 +1,7 @@ import crypto from "node:crypto"; import fs from "node:fs/promises"; import path from "node:path"; +import { inspect } from "node:util"; import { cancel, isCancel } from "@clack/prompts"; @@ -196,7 +197,14 @@ export async function probeGatewayReachable(params: { } function summarizeError(err: unknown): string { - const raw = String(err ?? "unknown error"); + let raw = "unknown error"; + if (err instanceof Error) { + raw = err.message || raw; + } else if (typeof err === "string") { + raw = err || raw; + } else if (err !== undefined) { + raw = inspect(err, { depth: 2 }); + } const line = raw .split("\n") diff --git a/src/commands/onboard-providers.ts b/src/commands/onboard-providers.ts index 43c63b44e..93cdd3a97 100644 --- a/src/commands/onboard-providers.ts +++ b/src/commands/onboard-providers.ts @@ -68,7 +68,7 @@ function setRoutingAllowFrom(cfg: ClawdisConfig, allowFrom?: string[]) { return { ...cfg, routing: { - ...(cfg.routing ?? {}), + ...cfg.routing, allowFrom, }, }; diff --git a/src/imessage/client.ts b/src/imessage/client.ts index 6a89f8c5b..efcdae28f 100644 --- a/src/imessage/client.ts +++ b/src/imessage/client.ts @@ -168,8 +168,9 @@ export class IMessageRpcClient { let parsed: IMessageRpcResponse; try { parsed = JSON.parse(line) as IMessageRpcResponse; - } catch (_err) { - this.runtime?.error?.(`imsg rpc: failed to parse ${line}`); + } catch (err) { + const detail = err instanceof Error ? err.message : String(err); + this.runtime?.error?.(`imsg rpc: failed to parse ${line}: ${detail}`); return; }