/** * Turning a WordPress failure into something the caller can act on. * * WordPress answers a failed REST call with a JSON body carrying a `code` and a * `message`, and those codes are precise: `rest_cannot_edit` is a capability * problem, `rest_post_invalid_id` is a bad argument, `rest_no_route` means the * endpoint is not registered on that install. The original version of this * server surfaced the raw response text, which meant a model saw a wall of HTML * or a bare code and had nothing to do differently on the retry. * * So every code that has a real fix gets a sentence naming the fix. The rest * fall through with the code and the site attached, because knowing which of * three sites refused is most of the diagnosis. */ export declare class WordPressError extends Error { readonly status: number; readonly code: string; readonly site: string; readonly endpoint: string; readonly detail?: string; constructor(init: { message: string; status: number; code: string; site: string; endpoint: string; detail?: string; }); toJSON(): Record; } /** * The helper plugin is not installed on this site. * * Worth its own type because it is the single most common failure on a fresh * setup and the fix is a file copy, not a permission change. Twelve of the tools * need it and the other thirty do not, so this has to say which is which * rather than reading as though the whole server is broken. */ export declare class HelperPluginMissingError extends Error { readonly site: string; constructor(site: string, tool: string); toJSON(): Record; } /** * Read a failed response into a typed error. * * The body is read as text first and parsed after, because a site behind a * security plugin or a WAF answers with HTML rather than JSON and calling * `.json()` on that throws a parse error that hides the real status. */ export declare function errorFromResponse(response: Response, site: string, endpoint: string): Promise; /** A network failure, before the site ever answered. */ export declare function networkError(error: unknown, site: string, url: string): WordPressError;