IF Commons GitHub

errors

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

What Microsoft Graph 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" } }); its kind is one of a closed list, decided by the code where there is one and by the status where there is not; and every kind is a problem of AnyFS by a total table written here, which the compiler holds. A condition that failed is a conflict only where the caller can say what the object is at; a throttle 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: 412, code: "preconditionFailed", message: "" }); // "precondition"
kindOf({ status: 429, code: "activityLimitReached", message: "" }); // "throttled"

Source: commons/anyfs-onedrive/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 code 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", "name-exists", "precondition", "locked", "throttled", "server", "denied", "bad-token", "too-large", "quota", "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" | "denied" | "invalid" | "locked" | "name-exists" | "not-found" | "precondition" | "quota" | "redirect" | "server" | "throttled" | "too-large"

The kind of a failure: its code 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. Missing and conflict are made by the caller, which knows what it asked; here they are the problems a caller that does not know gets.

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 code: 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.