fix: improve onboarding/imessage errors
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -68,7 +68,7 @@ function setRoutingAllowFrom(cfg: ClawdisConfig, allowFrom?: string[]) {
|
||||
return {
|
||||
...cfg,
|
||||
routing: {
|
||||
...(cfg.routing ?? {}),
|
||||
...cfg.routing,
|
||||
allowFrom,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -168,8 +168,9 @@ export class IMessageRpcClient {
|
||||
let parsed: IMessageRpcResponse<unknown>;
|
||||
try {
|
||||
parsed = JSON.parse(line) as IMessageRpcResponse<unknown>;
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user