import type { SuaveplanErrorOptions } from "@suaveplan/error"; import { defineCodes, SuaveplanError } from "@suaveplan/error"; /** * Stable error-code registry for `@suaveplan/email-processing`. * * Every code is thrown by at least one production code path under * `src/`. Removing an entry without removing its call site is forbidden * by ยง2c of `openspec/AGENTS.md`. */ export const EMAIL_PROCESSING_CODES = defineCodes("EMAIL_PROCESSING", [ "INVALID_INPUT", "PARSE_FAILURE", "INVALID_OPTIONS", "DKIM_VERIFY_FAILURE", "HOOK_FAILURE", ] as const); export type EmailProcessingCode = (typeof EMAIL_PROCESSING_CODES)[keyof typeof EMAIL_PROCESSING_CODES]; /** * Typed error class for every failure raised by this package. * * Extends `SuaveplanError` with a discriminant `code` drawn from * `EMAIL_PROCESSING_CODES`. The constructor is `public` so callers * outside the package can construct instances; `SuaveplanError`'s * constructor is `protected` and would otherwise be inaccessible. */ export class EmailProcessingError extends SuaveplanError { public constructor( code: EmailProcessingCode, messageKey: string, options?: SuaveplanErrorOptions ) { super(code, messageKey, options); this.name = "EmailProcessingError"; } }