# Errors

> USearch for Go

Every failure carries a status shared with the C interface, so a fault this binding catches before the boundary reports the identity the engine would have reported for the same fault.
A `Status` is itself an `error`, so `errors.Is` matches any failure carrying it, and an `*usearch.Error` adds its message:

```go
if err := index.Insert(keys, vectors, nil); err != nil {
	if errors.Is(err, usearch.StatusShapeMismatch) {
		// the keys and the rows disagree
}

	var failure *usearch.Error
	if errors.As(err, &failure) {
		fmt.Println(failure.Status, failure.Message)
}
}
```

`Status`, like `Mood`, `Residency`, `Traversal`, `DenseMetric` and `Scalar`, carries the C enumerators' values, and its `String` spells the name the C tables own.
`StatusUnsupported` marks a verb declared for every residency that this one does not implement yet, and `StatusContended` a call refused rather than waited for.

`import "github.com/unum-cloud/USearch/golang"`

## Error

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

```go
type Error struct {
    Status  Status
    Message string
}
```

Reach the status with errors.Is or errors.As.

## Error

Error implements the error interface.

```go
func (failure *Error) Error() string
```

## Unwrap

Unwrap exposes the status, which is what errors.Is compares.

```go
func (failure *Error) Unwrap() error
```

## Status

Status names what went wrong, in a vocabulary shared by the engine and by this binding.

```go
type Status int32
```

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

A Status is an error, so errors.Is(err, usearch.StatusReadOnly) matches any failure carrying it.

- `StatusSuccess`: StatusSuccess means the call completed and carries no message.
- `StatusDeferred`: StatusDeferred means the call was submitted deferred and is not final yet.
- `StatusOutOfMemory`: StatusOutOfMemory means an allocation or reservation could not be satisfied.
- `StatusShapeMismatch`: StatusShapeMismatch means dimensionality or row counts disagree.
- `StatusUnsupportedLayout`: StatusUnsupportedLayout means a stride or packing the engine cannot traverse.
- `StatusUnknownKind`: StatusUnknownKind means a scalar, metric, or residency tag this build does not know.
- `StatusReadOnly`: StatusReadOnly means a mutating verb reached a handle that serves its checkpoint in place.
- `StatusIO`: StatusIO means a file could not be opened, read, written, or parsed.
- `StatusDevice`: StatusDevice means a device could not be selected, or its memory could not be claimed.
- `StatusMalformed`: StatusMalformed means a caller-supplied representation could not be decoded.
- `StatusInternal`: StatusInternal means the library reported neither success nor a failure.
- `StatusOverflow`: StatusOverflow means a hard design ceiling was reached, like the 32-bit ID space.
- `StatusUninitialized`: StatusUninitialized means the verb needs a prior successful reservation that never happened.
- `StatusConfigMismatch`: StatusConfigMismatch means the request contradicts an already-frozen configuration.
- `StatusContended`: StatusContended means the call was refused rather than waited for, like a submission to a full deferred table, or an arena still serving another call.
- `StatusCancelled`: StatusCancelled means a progress handler asked the operation to stop; it unwound and published nothing, so the handle carries whatever it did before the call.
- `StatusUnsupported`: StatusUnsupported means the verb is declared for every residency but this one does not implement it; a caller picks another residency.
- `StatusInvalidArgument`: StatusInvalidArgument means an argument breaks the verb's contract, like a required value left nil.

## Error

Error implements the error interface, so a bare Status is an errors.Is target.

```go
func (status Status) Error() string
```

## String

String renders the status as the library spells it.

```go
func (status Status) String() string
```

