# Errors

> USearch for Java

Every failure is an unchecked `USearchException`, since nearly every verb can report one, and its `status()` is a `Status` mirroring the C interface's `usearch_status_*_k`.
Checks the SDK runs before a call crosses report the status the engine would have reported for the same fault, and a code this build cannot name reads as `Status.INVALID_ARGUMENT`, as in C.
`Status.DEFERRED` is the one non-final status, which only a `Deferred` reports before its call is final.
Any verb on a closed handle raises `IllegalStateException` instead.

```java
try {
    served.insert(keys, vectors);
} catch (USearchException failure) {
    if (failure.status() != Status.READ_ONLY) {
        throw failure;
}
}
```

`Status`, `Scalar`, `DenseMetric`, `Residency`, `Traversal` and `Mood` carry their C enumerators' values in `code()`, and their `toString` spells the names the C tables own, so nothing is compared as a string.

`import cloud.unum.usearch.*;`

## Status

What went wrong, in a vocabulary shared by the engine and by this binding - one enumerator per usearch_status_*_k, the deferred one included, which only a deferred call reports before it is final.

```java
enum Status
```

Validation performed here before a call crosses reports the status the engine would have reported for the same fault.

- `SUCCESS` ``: The call succeeded and carries no message.
- `DEFERRED` ``: The call was submitted deferred and is not final yet; the one non-final status.
- `OUT_OF_MEMORY` ``: An allocation or reservation could not be satisfied.
- `SHAPE_MISMATCH` ``: Dimensionality or row counts disagree.
- `UNSUPPORTED_LAYOUT` ``: A stride or packing the engine cannot traverse.
- `UNKNOWN_KIND` ``: A scalar, metric, or residency tag this build does not know.
- `READ_ONLY` ``: A mutating verb reached a handle that serves its checkpoint in place.
- `IO` ``: A file could not be opened, read, written, or parsed.
- `DEVICE` ``: A device could not be selected, or its memory could not be claimed.
- `MALFORMED` ``: A caller-supplied representation could not be decoded.
- `INTERNAL` ``: The library reported neither success nor a failure.
- `OVERFLOW` ``: A hard design ceiling was reached, like the 32-bit identity space.
- `UNINITIALIZED` ``: The verb needs a prior successful reservation that never happened.
- `CONFIG_MISMATCH` ``: The request contradicts an already-frozen configuration.
- `CONTENDED` ``: A synchronization contract was violated - a full deferred table, or a busy arena.
- `CANCELLED` ``: A progress handler asked the operation to stop; it unwound and published nothing, so the handle carries whatever it did before the call.
- `UNSUPPORTED` ``: The verb is declared for every residency but this one does not implement it.
- `INVALID_ARGUMENT` ``: An argument breaks the verb's contract, like a required one left null, or a status no build names.

## USearchException

One failed call: a status every caller can branch on, and the detail the status cannot carry.

```java
class USearchException
```

Nearly every verb can report one, so it is unchecked.

