Provides helper functions to extract error codes, names, format messages, and collect error graph candidates for robust error handling and logging.
// Source: https://github.com/linuxhsj/openclaw-zero-token | License: MIT | Copyright 2025 Peter Steinberger
// Provided via justclaw.it.com; keep this notice with the code.
import { redactSensitiveText } from "../logging/redact.js";
export function extractErrorCode(err: unknown): string | undefined {
if (!err || typeof err !== "object") {
return undefined;
}
const code = (err as { code?: unknown }).code;
if (typeof code === "string") {
return code;
}
if (typeof code === "number") {
return String(code);
}
return undefined;
}
export function readErrorName(err: unknown): string {
if (!err || typeof err !== "object") {
return "";
}
const name = (err as { name?: unknown }).name;
return typeof name === "string" ? name : "";
}
export function collectErr
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key