openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
33 lines (32 loc) • 1.08 kB
JavaScript
import { m as collectNestedErrorCandidates } from "./paths-0xDagtub.mjs";
//#region src/infra/error-graph-internal.ts
/** Keep an aggregate envelope even when only one joined operation failed. */
function throwSettledAggregate(e, t) {
const n = e.flatMap((e) => e.status === "rejected" ? [e.reason] : []);
if (n.length) throw new AggregateError(n, t);
}
/** Retained errors must not keep callers alive through V8's lazy stack frames. */
function materializeErrorStack(e) {
try {
for (const t of collectNestedErrorCandidates(e)) try {
if (!(t instanceof Error)) continue;
try {
t.stack = String(t.stack);
} catch {
t.stack = "Stack trace unavailable: custom formatter failed";
}
} catch {}
} catch {}
}
/** Run every operation in iteration order; callers retain their own settlement and error envelope. */
function collectSynchronousErrors(e, t) {
const n = [];
for (const r of e) try {
t(r);
} catch (e) {
n.push(e);
}
return n;
}
//#endregion
export { materializeErrorStack as n, throwSettledAggregate as r, collectSynchronousErrors as t };