refactor(infra): share error normalization · openclaw/openclaw@a29edce
vincentkoc
·
2026-06-22
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ import {
|
11 | 11 | } from "@openclaw/normalization-core/string-coerce"; |
12 | 12 | import { logVerbose } from "../globals.js"; |
13 | 13 | import { runExec } from "../process/exec.js"; |
| 14 | +import { toErrorObject } from "./errors.js"; |
14 | 15 | |
15 | 16 | function parsePossiblyNoisyJsonObject(stdout: string): Record<string, unknown> { |
16 | 17 | const trimmed = stdout.trim(); |
@@ -147,7 +148,7 @@ export async function getTailnetHostname(exec: typeof runExec = runExec, detecte
|
147 | 148 | } |
148 | 149 | } |
149 | 150 | |
150 | | -throw toLintErrorObject( |
| 151 | +throw toErrorObject( |
151 | 152 | lastError ?? new Error("Could not determine Tailscale DNS or IP"), |
152 | 153 | "Non-Error thrown", |
153 | 154 | ); |
@@ -475,17 +476,3 @@ export async function readTailscaleWhoisIdentity(
|
475 | 476 | return null; |
476 | 477 | } |
477 | 478 | } |
478 | | - |
479 | | -function toLintErrorObject(value: unknown, fallbackMessage: string): Error { |
480 | | -if (value instanceof Error) { |
481 | | -return value; |
482 | | -} |
483 | | -if (typeof value === "string") { |
484 | | -return new Error(value); |
485 | | -} |
486 | | -const error = new Error(fallbackMessage, { cause: value }); |
487 | | -if ((typeof value === "object" && value !== null) || typeof value === "function") { |
488 | | -Object.assign(error, value); |
489 | | -} |
490 | | -return error; |
491 | | -} |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。