mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 13:26:04 -06:00
refactor: consolidate remaining coercion helpers (#122020)
This commit is contained in:
committed by
GitHub
parent
24bbb416b5
commit
cad77fb39c
@@ -9,6 +9,7 @@ import {
|
||||
previewForDevToolLog,
|
||||
redactJsonValueForDevToolLog,
|
||||
} from "../lib/dev-tooling-safety.ts";
|
||||
import { toErrorObject as toLintErrorObject } from "../lib/error-format.mts";
|
||||
|
||||
const OPENAI_REALTIME_MODEL =
|
||||
process.env.OPENCLAW_REALTIME_OPENAI_MODEL?.trim() || "gpt-realtime-2.1";
|
||||
@@ -1170,17 +1171,3 @@ export const testing = {
|
||||
transcriptIncludesMarker,
|
||||
usage,
|
||||
};
|
||||
|
||||
function toLintErrorObject(value: unknown, fallbackMessage: string): Error {
|
||||
if (value instanceof Error) {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
return new Error(value);
|
||||
}
|
||||
const error = new Error(fallbackMessage, { cause: value });
|
||||
if ((typeof value === "object" && value !== null) || typeof value === "function") {
|
||||
Object.assign(error, value);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user