{"version":3,"file":"errors.mjs","names":[],"sources":["../../../../../../notifications/src/errors.ts"],"sourcesContent":["/**\n * Domain errors for `@warlock.js/notifications`. All extend `Error` directly\n * (no framework HttpError) so the package stays runtime-agnostic — the host\n * app maps them to its own error shape via `instanceof` if needed.\n *\n * Each captures a clean V8 stack (drops the Error-constructor frame) to match\n * the cascade convention.\n */\n\nfunction captureStack(target: object, ctor: new (...args: any[]) => unknown): void {\n  // V8 only; guarded for non-V8 runtimes.\n  (Error as unknown as { captureStackTrace?: (t: object, c: unknown) => void }).captureStackTrace?.(\n    target,\n    ctor,\n  );\n}\n\nexport class NotificationsNotConfiguredError extends Error {\n  public constructor() {\n    super(\n      \"Notifications not configured — add `src/config/notifications.ts` with a \" +\n        \"default-exported config; the notifications connector registers it at boot.\",\n    );\n    this.name = \"NotificationsNotConfiguredError\";\n    captureStack(this, NotificationsNotConfiguredError);\n  }\n}\n\nexport class ChannelNotFoundError extends Error {\n  public constructor(channelName: string) {\n    super(\n      `Channel \"${channelName}\" is not configured. Add it to the ` +\n        \"`channels` map in `src/config/notifications.ts`.\",\n    );\n    this.name = \"ChannelNotFoundError\";\n    captureStack(this, ChannelNotFoundError);\n  }\n}\n\nexport class NoQueueDispatcherError extends Error {\n  public constructor(channelName: string) {\n    super(\n      `Cannot queue to channel \"${channelName}\" — no queue dispatcher configured. ` +\n        \"Add a `queue` to `src/config/notifications.ts`, or call `.send()` instead of `.queue()`.\",\n    );\n    this.name = \"NoQueueDispatcherError\";\n    captureStack(this, NoQueueDispatcherError);\n  }\n}\n\nexport class MissingRendererError extends Error {\n  public constructor(notificationType: string, channelName: string) {\n    super(\n      `Notification \"${notificationType}\" routes to channel \"${channelName}\" via ` +\n        `\\`via\\` but defines no \\`${channelName}\\` renderer.`,\n    );\n    this.name = \"MissingRendererError\";\n    captureStack(this, MissingRendererError);\n  }\n}\n\n/**\n * Thrown when a channel's `route()` resolver runs but returns `undefined` for\n * a recipient (e.g. a mail recipient with no email). Distinct from \"the\n * channel declares no resolver\" — that case falls back to `{ id }`.\n */\nexport class UnresolvableRouteError extends Error {\n  public constructor(channelName: string, recipientId?: unknown) {\n    super(\n      `Channel \"${channelName}\" could not resolve a route for recipient ` +\n        `${recipientId ?? \"(unknown)\"}. The channel's \\`route()\\` returned undefined — ` +\n        \"the recipient is missing the address column this channel needs.\",\n    );\n    this.name = \"UnresolvableRouteError\";\n    captureStack(this, UnresolvableRouteError);\n  }\n}\n"],"mappings":";;;;;;;;;AASA,SAAS,aAAa,QAAgB,MAA6C;CAEjF,AAAC,MAA6E,oBAC5E,QACA,IACF;AACF;AAEA,IAAa,kCAAb,MAAa,wCAAwC,MAAM;CACzD,AAAO,cAAc;EACnB,MACE,oJAEF;EACA,KAAK,OAAO;EACZ,aAAa,MAAM,+BAA+B;CACpD;AACF;AAEA,IAAa,uBAAb,MAAa,6BAA6B,MAAM;CAC9C,AAAO,YAAY,aAAqB;EACtC,MACE,YAAY,YAAY,wFAE1B;EACA,KAAK,OAAO;EACZ,aAAa,MAAM,oBAAoB;CACzC;AACF;AAEA,IAAa,yBAAb,MAAa,+BAA+B,MAAM;CAChD,AAAO,YAAY,aAAqB;EACtC,MACE,4BAA4B,YAAY,qIAE1C;EACA,KAAK,OAAO;EACZ,aAAa,MAAM,sBAAsB;CAC3C;AACF;AAEA,IAAa,uBAAb,MAAa,6BAA6B,MAAM;CAC9C,AAAO,YAAY,kBAA0B,aAAqB;EAChE,MACE,iBAAiB,iBAAiB,uBAAuB,YAAY,iCACvC,YAAY,aAC5C;EACA,KAAK,OAAO;EACZ,aAAa,MAAM,oBAAoB;CACzC;AACF;;;;;;AAOA,IAAa,yBAAb,MAAa,+BAA+B,MAAM;CAChD,AAAO,YAAY,aAAqB,aAAuB;EAC7D,MACE,YAAY,YAAY,4CACnB,eAAe,YAAY,iHAElC;EACA,KAAK,OAAO;EACZ,aAAa,MAAM,sBAAsB;CAC3C;AACF"}