/** * Typed errors for every way a Substack call can fail. * * Substack has no public API. We call the same authenticated JSON endpoints the * web app calls, so failures arrive in three different shapes: a JSON body, a * plain-text body, or a multi-kilobyte Cloudflare HTML block page. A single * "Substack API error" string for all of them tells the calling model nothing * it can act on, so each status maps to a class with a message that names the * actual fix. */ export declare class SubstackError extends Error { readonly status: number; readonly endpoint: string; readonly detail: string; constructor(message: string, status: number, endpoint: string, detail?: string); /** What the model should show the user. Includes the actionable hint. */ toJSON(): Record; } /** 401/403, or a Cloudflare 1010 block on a custom domain. */ export declare class AuthenticationError extends SubstackError { } /** 429. Substack does not send Retry-After, so the client backs off on its own. */ export declare class RateLimitError extends SubstackError { } /** 400 — bad arguments reached the endpoint. */ export declare class ValidationError extends SubstackError { } /** 404 — the draft, post, note or publication does not exist. */ export declare class NotFoundError extends SubstackError { } /** 5xx — Substack's problem, worth retrying. */ export declare class ServerError extends SubstackError { } /** Synthetic 408. No response arrived before our own deadline. */ export declare class TimeoutError extends SubstackError { } /** The server is running with writes disabled, or a confirm was missing. */ export declare class WriteBlockedError extends SubstackError { constructor(message: string); } /** * Pull something readable out of a response body. * * Tries JSON first (`{error}` / `{errors:[]}` / `{message}`), falls back to raw * text. Caps at 500 characters so a Cloudflare HTML block page does not become * the entire error message. */ export declare function extractErrorDetail(body: string): string; /** True when a Cloudflare block page is pretending to be an auth failure. */ export declare function isCloudflareBlock(body: string): boolean; /** Map an HTTP status onto the right error class. */ export declare function errorForStatus(status: number, endpoint: string, body: string): SubstackError;