/** * Typed error hierarchy for Siteping client/server boundaries. * * Consumers can `instanceof`-check or read `code` / `retryable` instead of * pattern-matching error messages. Designed to be additive on top of the * existing store errors (`StoreNotFoundError`, `StoreDuplicateError`) which * remain the canonical signals for server-side store implementations. * * Usage on the widget side (api-client.ts): * - fetch failures / aborts / timeouts → `SitepingNetworkError` (retryable) * - HTTP 4xx (except 401/403) → `SitepingValidationError` (not retryable) * - HTTP 401 / 403 → `SitepingAuthError` (not retryable) * - everything else → `SitepingError` generic * * Store mode (store-client.ts): a `createFeedback` that does not settle in * time → `SitepingError` with code `"TIMEOUT"` (retryable). * * `retryable` is meta information surfaced to host apps that want to wire * their own retry/queue/backoff strategy — the widget already retries * network failures via its built-in retry queue. */ /** * Discriminant string carried by every `SitepingError`. Subclasses pin a * literal value; the base class accepts a wider string so userland can * extend the hierarchy without colliding with built-ins. */ export type SitepingErrorCode = "NETWORK" | "VALIDATION" | "AUTH" | "SERVER" | "TIMEOUT" | (string & {}); export declare class SitepingError extends Error { readonly code: TCode; readonly retryable: boolean; constructor(message: string, code: TCode, retryable: boolean); } /** Network-level failure: connection refused, DNS, CORS, timeout, abort. Retryable. */ export declare class SitepingNetworkError extends SitepingError<"NETWORK"> { constructor(message: string); } /** * Server rejected the request (4xx, not auth). Validation problem on the * client side. `status` is the HTTP status when a response said so: a 404 * (the target is gone) and a 409 (a full thread) call for other answers * than a 400. */ export declare class SitepingValidationError extends SitepingError<"VALIDATION"> { readonly status: number | undefined; constructor(message: string, status?: number); } /** Server rejected auth (401 or 403). Not retryable without fresh credentials. */ export declare class SitepingAuthError extends SitepingError<"AUTH"> { /** * `401`: the credentials are missing or no longer work — drop a dead token * on this one. `403`: they work, and the server's policy refuses this request. */ readonly status: 401 | 403; constructor(message: string, status: 401 | 403); }