# Errors

> UForm for Swift

`UFormError` is the only error the SDK throws, and every method says so with `throws(UFormError)`, so a `catch` reads `error.status` with no cast.
`Status` has one constant per `uform_status_*_k` of the C interface, and its `description` spells it as the library does, like `invalid-argument`.

```swift
do {
    _ = try Model.loadRam(path: "missing.safetensors")
} catch {
    print(error.status, error.message) // io The checkpoint could not be opened for reading
}
```

`Scalar`, `Mood` and every other closed set read a spelling back with `init?(name:)`, and nil for one the library does not spell.

`import UForm`

## Status

What went wrong, in the vocabulary the library and every binding share - one constant per `uform_status_*_k`, carrying the C enumerator itself.

```swift
struct Status
```

A [`UFormError`](#UFormError) never carries [`success`](#success) or [`deferred`](#deferred); a [`Deferred`](https://www.unum.cloud/docs/uform/swift/receivers-and-deferred-calls.md#Deferred) call reports both.

Conforms to: `Hashable`, `Sendable`, `CustomStringConvertible`, `Equatable`

## success

The call succeeded and carries no message.

```swift
static let success: Status
```

## deferred

The call was submitted deferred and is not final yet.

```swift
static let deferred: Status
```

## outOfMemory

Device, pinned or host memory could not be allocated.

```swift
static let outOfMemory: Status
```

## shapeMismatch

Item counts, a pixel shape or a batch envelope disagree with the call or the model.

```swift
static let shapeMismatch: Status
```

## unsupportedLayout

A stride or packing the model cannot read.

```swift
static let unsupportedLayout: Status
```

## unknownKind

A scalar, modality or name this build does not know.

```swift
static let unknownKind: Status
```

## io

A checkpoint file could not be opened, read or written.

```swift
static let io: Status
```

## device

The driver refused or the device faulted.

```swift
static let device: Status
```

## malformed

Supplied bytes could not be decoded.

```swift
static let malformed: Status
```

## internal

The library reported neither success nor a failure.

```swift
static let `internal`: Status
```

## configMismatch

The request contradicts a frozen configuration.

```swift
static let configMismatch: Status
```

## contended

A call was refused rather than waited for - a full deferred table, or an arena serving another call.

```swift
static let contended: Status
```

## cancelled

A progress handler asked the call to stop; it unwound and published nothing.

```swift
static let cancelled: Status
```

## unsupported

The verb is declared, but this residency or model does not implement it.

```swift
static let unsupported: Status
```

## invalidArgument

An argument breaks the verb's contract.

```swift
static let invalidArgument: Status
```

## description

The status as the library spells it, like `invalid-argument`.

```swift
var description: String { get }
```

Calls `uform_status_name`.

## init

Reads a spelling back, and nil for one no status carries.

```swift
init?(name: String)
```

Calls `uform_status_from_name`.

## UFormError

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

```swift
struct UFormError
```

Conforms to: `Error`, `CustomStringConvertible`, `Equatable`, `Sendable`

## status

The failure identity, shared with every other SDK.

```swift
let status: Status
```

## message

The library's static detail, or this binding's own when it refused the call.

```swift
let message: String
```

## description

The status and message, as `uform: <status>: <message>`.

```swift
var description: String { get }
```

