UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

24 lines (23 loc) • 785 B
//#region src/infra/fatal-error-hooks.ts const hooks = /* @__PURE__ */ new Set(); /** Registers a fatal-error hook and returns an unsubscribe callback. */ function registerFatalErrorHook(hook) { hooks.add(hook); return () => { hooks.delete(hook); }; } /** Runs registered fatal-error hooks and returns non-empty diagnostic lines. */ function runFatalErrorHooks(context) { const messages = []; for (const hook of hooks) try { const message = hook(context); if (typeof message === "string" && message.trim()) messages.push(message); } catch (err) { const name = err instanceof Error && err.name ? err.name : "unknown"; messages.push(`fatal-error hook failed: ${name}`); } return messages; } //#endregion export { runFatalErrorHooks as n, registerFatalErrorHook as t };