fix: improve onboarding/imessage errors

This commit is contained in:
Peter Steinberger
2026-01-02 12:20:48 +01:00
parent fd4cff06ca
commit eaacebeecc
3 changed files with 13 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
import crypto from "node:crypto"; import crypto from "node:crypto";
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import path from "node:path"; import path from "node:path";
import { inspect } from "node:util";
import { cancel, isCancel } from "@clack/prompts"; import { cancel, isCancel } from "@clack/prompts";
@@ -196,7 +197,14 @@ export async function probeGatewayReachable(params: {
} }
function summarizeError(err: unknown): string { 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 = const line =
raw raw
.split("\n") .split("\n")

View File

@@ -68,7 +68,7 @@ function setRoutingAllowFrom(cfg: ClawdisConfig, allowFrom?: string[]) {
return { return {
...cfg, ...cfg,
routing: { routing: {
...(cfg.routing ?? {}), ...cfg.routing,
allowFrom, allowFrom,
}, },
}; };

View File

@@ -168,8 +168,9 @@ export class IMessageRpcClient {
let parsed: IMessageRpcResponse<unknown>; let parsed: IMessageRpcResponse<unknown>;
try { try {
parsed = JSON.parse(line) as IMessageRpcResponse<unknown>; parsed = JSON.parse(line) as IMessageRpcResponse<unknown>;
} catch (_err) { } catch (err) {
this.runtime?.error?.(`imsg rpc: failed to parse ${line}`); const detail = err instanceof Error ? err.message : String(err);
this.runtime?.error?.(`imsg rpc: failed to parse ${line}: ${detail}`);
return; return;
} }