mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 12:11:36 +00:00
refactor(core): dedupe shared config and runtime helpers
This commit is contained in:
23
src/memory/batch-error-utils.ts
Normal file
23
src/memory/batch-error-utils.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
type BatchOutputErrorLike = {
|
||||
error?: { message?: string };
|
||||
response?: {
|
||||
body?: {
|
||||
error?: { message?: string };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export function extractBatchErrorMessage(lines: BatchOutputErrorLike[]): string | undefined {
|
||||
const first = lines.find((line) => line.error?.message || line.response?.body?.error);
|
||||
return (
|
||||
first?.error?.message ??
|
||||
(typeof first?.response?.body?.error?.message === "string"
|
||||
? first?.response?.body?.error?.message
|
||||
: undefined)
|
||||
);
|
||||
}
|
||||
|
||||
export function formatUnavailableBatchError(err: unknown): string | undefined {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
return message ? `error file unavailable: ${message}` : undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user