failureOffunctionfunction failureOf(status: number, headers: Readonly<Record<string, string>>, body: Uint8Array<ArrayBufferLike>): FailureThe failure of an answer: the status, the reason and the message of its error object, as far as it has them.
What the Drive API says when it does not do what it was asked, and what a store makes of it: a failure is a status and an error object ({ "error": { "code", "message", "errors": [{ "reason" }] } }); its kind is one of a closed list, decided by the reason where there is one and by the status where there is not (a 403 is a rate limit, a quota or a denial by its reason); and every kind is a problem of AnyFS by a total table written here, which the compiler holds. A rate limit or a fault of the service is a problem worth a retry; a refusal of the token or of the account is not, and says which it was.
import { kindOf } from "./errors.ts";
kindOf({ status: 403, reason: "userRateLimitExceeded", message: "" }); // "throttled"
kindOf({ status: 403, reason: "forbidden", message: "" }); // "denied"failureOffunctionfunction failureOf(status: number, headers: Readonly<Record<string, string>>, body: Uint8Array<ArrayBufferLike>): FailureThe failure of an answer: the status, the reason and the message of its error object, as far as it has them.
FAILURE_KINDSconstconst FAILURE_KINDS: readonly ["not-found", "throttled", "server", "denied", "bad-token", "quota", "too-large", "conflict", "invalid", "redirect"]The kinds of failure: a closed list.
kindOffunctionfunction kindOf(f: Failure): "bad-token" | "conflict" | "denied" | "invalid" | "not-found" | "quota" | "redirect" | "server" | "throttled" | "too-large"The kind of a failure: its reason where there is one, else its status.
problemOffunctionfunction problemOf(f: Failure, subject: Subject): ProblemThe problem a failure is.
Failuretypeno test imports ittype Failure = { readonly status: number; readonly reason: string; readonly message: string; readonly retryAfterMs?: number };What the service answered when it failed.
FailureKindtypeno test imports ittype FailureKind = (typeof FAILURE_KINDS)[number];One kind of failure.