Swift · Errors

Errors

import USearch 3.0.0-rc.1 · 4c3e5023

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

do {
    try index.reserve(1 << 40)
} catch {
    print(error.status, error.message)
}

NumKong exports a Status of its own, so a file importing both spells this one USearch.Status.

API

StructStatusWhat went wrong, in the vocabulary the engine and this binding share - one constant per engine status.20
Types.swift:27 ↗
struct Status

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

A USearchError never carries success or deferred; a Deferred call reports both.

Conforms to

Hashable, Sendable, CustomStringConvertible, Equatable
successThe call succeeded and carries no message.
Types.swift:32 ↗
static let success: Status
deferredThe call was submitted deferred and is not final yet.
Types.swift:34 ↗
static let deferred: Status
outOfMemoryAn allocation or reservation could not be satisfied.
Types.swift:36 ↗
static let outOfMemory: Status
shapeMismatchDimensionality or row counts disagree.
Types.swift:38 ↗
static let shapeMismatch: Status
unsupportedLayoutA stride or packing the engine cannot traverse.
Types.swift:40 ↗
static let unsupportedLayout: Status
unknownKindA scalar, metric, or residency tag this build does not know.
Types.swift:42 ↗
static let unknownKind: Status
readOnlyA mutating verb reached a handle that serves its checkpoint in place.
Types.swift:44 ↗
static let readOnly: Status
ioA file could not be opened, read, written, or parsed.
Types.swift:46 ↗
static let io: Status
deviceA device could not be selected, or its memory could not be claimed.
Types.swift:48 ↗
static let device: Status
malformedA caller-supplied representation could not be decoded.
Types.swift:50 ↗
static let malformed: Status
internalThe library reported neither success nor a failure.
Types.swift:52 ↗
static let `internal`: Status
overflowA hard design ceiling was reached, like the 32-bit ID space.
Types.swift:54 ↗
static let overflow: Status
uninitializedThe verb needs a prior successful reservation that never happened.
Types.swift:56 ↗
static let uninitialized: Status
configMismatchThe request contradicts an already-frozen configuration.
Types.swift:58 ↗
static let configMismatch: Status
contendedA call was refused rather than waited for - a full deferred table, a busy arena, or a blocking call from inside a callback of the executor it would wait on.
Types.swift:61 ↗
static let contended: Status
cancelledA progress handler asked the operation to stop; what the finished increments leave behind is each verb's own contract.
Types.swift:64 ↗
static let cancelled: Status
unsupportedThe verb is declared for every residency but this one does not implement it.
Types.swift:66 ↗
static let unsupported: Status
invalidArgumentAn argument breaks the verb's contract.
Types.swift:68 ↗
static let invalidArgument: Status
descriptionThe status rendered as the library spells it, like invalid-argument.
Types.swift:71 ↗
var description: String { get }
initReads a spelling back, and nil for one no status carries.
Types.swift:74 ↗
init?(name: String)
StructUSearchErrorOne failed call: a status every caller can branch on, and the detail the status cannot carry.5
Types.swift:84 ↗
struct USearchError

Conforms to

Error, CustomStringConvertible, Equatable, Sendable
statusThe failure identity, shared with every other SDK.
Types.swift:86 ↗
let status: Status
messageThe library's static detail, or this binding's own when it rejected the call.
Types.swift:88 ↗
let message: String
causeWhat a caller's closure threw to stop the call, and nil for every other failure.
Types.swift:90 ↗
let cause: (any Swift.Error)?
description
Types.swift:92 ↗
var description: String { get }
==Equal in status and message, which is as far as an arbitrary cause compares.
Types.swift:120 ↗
static func == (left: USearchError, right: USearchError) -> Bool