describeFailurefunctionfunction describeFailure(f: Failure): stringThe failure in one sentence, which holds no credential.
What S3 says when it does not do what it was asked, and what a store makes of it: a failure is a status, a code and a message; its kind is one of thirteen, decided by the code where there is one and by the status where there is not (a HEAD has no body); and every kind is a problem of AnyFS by a total table written here, which the compiler holds. A failed condition is a conflict only where the caller can say what the object is at; a throttle or a fault of the server is a problem worth a retry; a refusal of the credentials is not, and says which of the several things it was.
import { kindOf } from "./errors.ts";
kindOf({ status: 412, code: "PreconditionFailed", message: "" }); // "precondition"
kindOf({ status: 503, code: "SlowDown", message: "" }); // "throttled"describeFailurefunctionfunction describeFailure(f: Failure): stringThe failure in one sentence, which holds no credential.
Failuretypeno test imports ittype Failure = { readonly status: number; readonly code: string; readonly message: string; readonly requestId?: string };What a service answered when it failed.
FAILURE_KINDSconstconst FAILURE_KINDS: readonly ["not-found", "no-bucket", "precondition", "in-progress", "throttled", "server", "denied", "bad-credentials", "clock-skew", "too-large", "bad-digest", "redirect", "not-implemented", "invalid"]The kinds of failure: a closed list.
FailureKindtypeno test imports ittype FailureKind = (typeof FAILURE_KINDS)[number];One kind of failure.
kindOffunctionfunction kindOf(failure: Failure): "bad-credentials" | "bad-digest" | "clock-skew" | "denied" | "in-progress" | "invalid" | "no-bucket" | "not-found" | "not-implemented" | "precondition" | "redirect" | "server" | "throttled" | "too-large"The kind of a failure: by its code where it has one that is known, else by its status.
problemOffunctionfunction problemOf(failure: Failure, subject?: Subject): ProblemThe problem of AnyFS a failure stands for.
Subjecttypeno test imports ittype Subject = { readonly path?: Path; readonly expect?: Expect; readonly found?: Found; readonly bucket?: string };What the caller knows of the object a failure is about.