> ## Documentation Index
> Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors (Swift)

> VoltaireError and error handling

# Errors

Swift wrappers throw `VoltaireError` when C calls return non-zero error codes.

## VoltaireError

```swift theme={null}
public enum VoltaireError: Error, Equatable {
    case invalidHex
    case invalidLength
    case invalidChecksum
    case outOfMemory
    case invalidInput
    case invalidSignature
    case invalidSelector
    case unsupportedType
    case maxLengthExceeded
    case invalidAccessList
    case invalidAuthorization
    case unknown(Int32)
}
```

## Handling Errors

```swift theme={null}
do {
  let v = try U256(hex: "0xz")
} catch let e as VoltaireError {
  switch e {
  case .invalidHex: print("Bad hex")
  default: print("Other error: \(e)")
  }
}
```
