IF Commons GitHub

errors

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-anyfs-s3-store FR-004

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"

Source: commons/anyfs-s3/src/errors.ts

4 of 7 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

describeFailurefunction
function describeFailure(f: Failure): string

The failure in one sentence, which holds no credential.

Imported by 3 tests of the run (3 passed, 0 failed): the library's results

Failuretypeno test imports it
type Failure = { readonly status: number; readonly code: string; readonly message: string; readonly requestId?: string };

What a service answered when it failed.

FAILURE_KINDSconst
const 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.

Imported by 3 tests of the run (3 passed, 0 failed): the library's results

FailureKindtypeno test imports it
type FailureKind = (typeof FAILURE_KINDS)[number];

One kind of failure.

kindOffunction
function 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.

Imported by 3 tests of the run (3 passed, 0 failed): the library's results

problemOffunction
function problemOf(failure: Failure, subject?: Subject): Problem

The problem of AnyFS a failure stands for.

Imported by 3 tests of the run (3 passed, 0 failed): the library's results

Subjecttypeno test imports it
type Subject = { readonly path?: Path; readonly expect?: Expect; readonly found?: Found; readonly bucket?: string };

What the caller knows of the object a failure is about.

Titles, headings, exports, tables, columns and requirements. Esc closes.