IF Commons GitHub

errors

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

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"

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

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

failureOffunction
function failureOf(status: number, headers: Readonly<Record<string, string>>, body: Uint8Array<ArrayBufferLike>): Failure

The failure of an answer: the status, the reason and the message of its error object, as far as it has them.

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

FAILURE_KINDSconst
const FAILURE_KINDS: readonly ["not-found", "throttled", "server", "denied", "bad-token", "quota", "too-large", "conflict", "invalid", "redirect"]

The kinds of failure: a closed list.

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

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

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

problemOffunction
function problemOf(f: Failure, subject: Subject): Problem

The problem a failure is.

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

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

What the service answered when it failed.

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

One kind of failure.

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