openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 926 B
JavaScript
import{i as collectNestedErrorCandidates}from"./error-coercion-DlKnt6w-.mjs";import{n as sliceUtf16Safe}from"./utf16-slice-DA3Mllbx.mjs";import{c as redactSensitiveText}from"./redact-BT59pdZ_.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";
//!src/infra/error-diagnostics.ts
const diagnostics=/* @__PURE__ */ new WeakMap;function attachErrorDiagnostic(e,t){diagnostics.set(e,sliceUtf16Safe(redactSensitiveText(t,{mode:`tools`}),0,2048).trim());return e}function findErrorDiagnostic(e){for(const t of collectNestedErrorCandidates(e)){const e=t&&typeof t===`object`?diagnostics.get(t):void 0;if(e)return e}}function copyErrorDiagnostic(e,t){const n=findErrorDiagnostic(e);if(n)diagnostics.set(t,n)}function formatErrorMessageForDisplay(e,t=formatErrorMessage(e)){const n=findErrorDiagnostic(e);return n?`${t}\n${n}`:t}export{copyErrorDiagnostic as n,formatErrorMessageForDisplay as r,attachErrorDiagnostic as t};