# Errors

> USearch for JavaScript

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`:

```javascript
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`.

`import * as usearch from 'usearch';`

## Status

What went wrong, one member per failure the library reports, spelled as its canonical name.

```typescript
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`](#Deferred) also reports [`Success`](#Success), and [`Deferred`](#Deferred) until its call is final.

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

## USearchError

An error thrown by the library or this binding, its `code` naming the failure.

```typescript
interface USearchError extends Error
```

- `code` `Status`

