/** * Structured errors for the shared font module, following the repo convention * (see root CLAUDE.md "Structured errors"): a plain `Error` with a * semver-stable `code` and JSON-serializable `details` (with `details.reason` * as the fine grain). Branch on `err.code`/`err.details.reason`, never on the * message. The factory lives in @polotno/core/errors. * * This module owns the font-domain classification. The reasons match the * canonical `FONT_FAILED` table so consumers (pdf-export, polotno-node) can * re-surface them unchanged: * - 'not-found' — the family isn't registered and isn't a Google font * (HTTP 4xx / empty Google response). The font does not * exist; retrying will not help. * - 'fetch-failed' — a genuine transport failure (offline, DNS, TLS, or * 5xx/429 that survived all retries). Distinct from * 'not-found' so callers can say "network problem" vs * "unknown font". * - 'decode-failed'— bytes were fetched but aren't a valid font. * - 'timeout' — the fetch didn't resolve within the timeout budget. */ import { type FontFailedReason, type PolotnoError as CorePolotnoError, type PolotnoErrorDetailsMap, type TypedPolotnoError } from '../errors.js'; export type { FontFailedReason }; export type PolotnoErrorCode = 'FONT_FAILED' | 'FETCH_FAILED'; export type PolotnoError = CorePolotnoError; export declare const polotnoError: TypedPolotnoError; /** The `FONT_FAILED` fields the caller supplies; `reason` is injected. */ type FontFailedDetails = Omit; export declare function fontFailed(reason: FontFailedReason, message: string, details?: FontFailedDetails, cause?: unknown): PolotnoError; /** True for our transport-level `FETCH_FAILED` (from `fetchFontResource`). */ export declare function isFetchFailed(err: unknown): err is PolotnoError; export declare function isFontFailed(err: unknown): err is PolotnoError;