JavaScript · Errors

Errors

import * as uform from 'uform'; 4.0.0-rc.1 · 3ee5e534

Every error carries a code from the Status enum, spelled as the C library names it, so a caller branches on the identity of the fault:

import { Model, Status } from "@unum-cloud/uform";

try {
  Model.loadRam("missing.safetensors");
} catch (error) {
  if (error.code === Status.Io) console.log("no such checkpoint");
}

API

Types

StatusWhat went wrong, one member per uform_status_*_k of the C interface and spelled as its canonical name.
uform.ts:19 ↗
enum Status

Every error the library or this binding throws carries one as its code, so a caller branches on the identity of the fault rather than on which side of the boundary saw it. A Deferred also reports Success, and Deferred until its call is final.

Values

Success"success"
Deferred"deferred"
OutOfMemory"out-of-memory"
ShapeMismatch"shape-mismatch"
UnsupportedLayout"unsupported-layout"
UnknownKind"unknown-kind"
Io"io"
Device"device"
Malformed"malformed"
Internal"internal"
ConfigMismatch"config-mismatch"
Contended"contended"
Cancelled"cancelled"
Unsupported"unsupported"
InvalidArgument"invalid-argument"
UFormErrorAn error thrown by the library or this binding, its code naming the failure.
uform.ts:38 ↗
interface UFormError extends Error

Fields

codeStatus