JavaScript · Errors

Errors

import * as usearch from 'usearch'; 3.0.0-rc.1 · 4c3e5023

Failures throw an Error whose code is a usearch.Status, one member per status of the C interface, spelled as its canonical name such as 'shape-mismatch'. Refusals this binding raises before a call crosses carry the same codes, so a caller branches on the fault rather than on which side of the boundary saw it. The engine checks every row’s width against the geometry it froze, so a narrow row surfaces as its ShapeMismatch:

try {
  index.insert(43n, new Float32Array([0.2, 0.6]));
} catch (error) {
  assert(error.code === usearch.Status.ShapeMismatch);
}

TypeScript callers can narrow a caught value to the exported USearchError type, an Error with that code.

API

Types

StatusWhat went wrong, one member per failure the library reports, spelled as its canonical name.
usearch.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"The call succeeded.
Deferred"deferred"The call was submitted deferred and is not final yet; the one non-final status.
OutOfMemory"out-of-memory"An allocation or reservation could not be satisfied.
ShapeMismatch"shape-mismatch"Dimensionality or row counts disagree.
UnsupportedLayout"unsupported-layout"A stride or packing the engine cannot traverse.
UnknownKind"unknown-kind"A scalar, metric, residency, traversal or relation this build does not know.
ReadOnly"read-only"A mutating verb on an index that serves its checkpoint in place.
Io"io"A file could not be opened, read, written or parsed.
Device"device"A device could not be selected, or its memory could not be claimed.
Malformed"malformed"A caller-supplied representation could not be decoded, like a truncated checkpoint.
Internal"internal"The library reported neither success nor a failure, which names a defect, not a state.
Overflow"overflow"A hard design ceiling was reached, like the 32-bit ID space; a smaller request cannot help.
Uninitialized"uninitialized"The verb needs a prior successful reservation that never happened.
ConfigMismatch"config-mismatch"The request contradicts a frozen configuration, like re-reserving with another geometry.
Contended"contended"The call was refused rather than waited for, like a submission to a full deferred table.
Cancelled"cancelled"A progress handler asked the operation to stop; it published nothing.
Unsupported"unsupported"This residency, traversal, predicate or build does not implement the request; pick another.
InvalidArgument"invalid-argument"An argument breaks the verb's contract, like a missing input or a name no table spells.
USearchErrorAn error thrown by the library or this binding, its code naming the failure.
usearch.ts:59 ↗
interface USearchError extends Error

Fields

codeStatus