/** * Structured errors, Node.js-style: a plain `Error` with a semver-stable * `code` property (branch on it, like `err.code === 'ENOENT'`) and optional * JSON-serializable `details`. Messages are for humans and may change in any * release — never match on them. No classes, no instanceof — a code check * works on any copy of any package. See the error-codes table in the repo * root CLAUDE.md. * * `@polotno/schema` is the layer *below* `@polotno/core`, so it can't import * core's shared error map — it defines its own. It only ever throws * `DESIGN_INVALID`; the `details` shape here is kept identical to core's entry * for that code, so a consumer sees the same fields whichever layer threw it. */ /** Codes thrown by this package. Append-only. */ export type PolotnoErrorCode = 'DESIGN_INVALID'; /** Exhaustive `details` shape per code (only `DESIGN_INVALID` here). */ export interface PolotnoErrorDetailsMap { DESIGN_INVALID: { errors: { path: string; message: string; }[]; /** Recognised element types, when the design references an unknown one. */ knownTypes?: string[]; }; } export type PolotnoError = { [K in Code]: Error & { code: K; details?: PolotnoErrorDetailsMap[K]; cause?: unknown; }; }[Code]; export declare function polotnoError(code: Code, message: string, details?: PolotnoErrorDetailsMap[Code], cause?: unknown): PolotnoError;