import { defineCodes, SuaveplanError, type SuaveplanErrorOptions, } from "@suaveplan/error"; /** * Stable error code registry for `@suaveplan/emblem-solver`. * * Codes are namespaced under `EMBLEM_SOLVER.*` so structured error logs and * OTel span events can be filtered by the package they originated in. */ export const EMBLEM_SOLVER_CODES = defineCodes("EMBLEM_SOLVER", [ "INVALID_GRID", "INVALID_OPTIONS", "INVALID_PIXEL", ] as const); export type EmblemSolverCode = (typeof EMBLEM_SOLVER_CODES)[keyof typeof EMBLEM_SOLVER_CODES]; /** * Typed error for all `@suaveplan/emblem-solver` failures. * * Extends `SuaveplanError` with a stable code drawn from * `EMBLEM_SOLVER_CODES`. Callers can discriminate on `error.code` to * handle specific failure modes (e.g. retry on `INVALID_PIXEL`, surface * `INVALID_OPTIONS` directly to the user). */ export class EmblemSolverError extends SuaveplanError { public constructor( code: EmblemSolverCode, messageKey: string, options?: SuaveplanErrorOptions ) { super(code, messageKey, options); this.name = "EmblemSolverError"; } }