{"version":3,"file":"capture-unhandled-errors.mjs","names":[],"sources":["../../../../../../../@warlock.js/logger/src/utils/capture-unhandled-errors.ts"],"sourcesContent":["import { log } from \"../logger\";\r\n\r\n/**\r\n * Route Node's process-level failure events through the logger so they land in\r\n * every configured channel with full stack context. Registers one listener for\r\n * `unhandledRejection` and one for `uncaughtException`; call once at startup\r\n * after channels are configured. Pair with `autoFlushOn: [\"beforeExit\"]` so the\r\n * final entry survives the process exit that follows an uncaught exception.\r\n *\r\n * Levels chosen for semantic honesty:\r\n *\r\n * - `uncaughtException` → `log.fatal` — by default Node terminates the process,\r\n *   so the failure is unrecoverable.\r\n * - `unhandledRejection` → `log.error` — a rejected promise is a failure, but\r\n *   not necessarily process-ending (depends on Node's `--unhandled-rejections`\r\n *   policy and your app's recovery), so it stays at error.\r\n *\r\n * @example\r\n * log.configure({ channels: [new ConsoleLog(), new FileLog()] });\r\n * captureAnyUnhandledRejection();\r\n */\r\nexport function captureAnyUnhandledRejection() {\r\n  process.on(\"unhandledRejection\", (reason: any) => {\r\n    log.error(\"app\", \"unhandledRejection\", reason);\r\n  });\r\n\r\n  process.on(\"uncaughtException\", (error) => {\r\n    log.fatal(\"app\", \"uncaughtException\", error);\r\n  });\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,+BAA+B;CAC7C,QAAQ,GAAG,uBAAuB,WAAgB;EAChD,IAAI,MAAM,OAAO,sBAAsB,MAAM;CAC/C,CAAC;CAED,QAAQ,GAAG,sBAAsB,UAAU;EACzC,IAAI,MAAM,OAAO,qBAAqB,KAAK;CAC7C,CAAC;AACH"}