Go · Errors

Errors

import "github.com/unum-cloud/ustore" 1.0.0-rc.1 · 084197c4

Ask your coding agent about this page, or add the docs server to it

curl -s 'https://www.unum.cloud/docs/ustore/go/errors.md' | claude -p "How would this fit my code?"

Every fallible verb answers an error, a *Error carrying the Status the C ABI reported and the static message beside it, so errors.Is matches it against a bare Status and errors.As reaches the message. A closed handle is refused with StatusUninitialized before anything crosses, and a batch whose runs disagree in length with StatusInvalidArgument. Status, Durability, Watch, Modality and the other enums print through String and parse through their FromName functions the spellings the C tables own, such as "not-found" or "strict-serializable".

_, err := database.CollectionCreate("people", ustore.ModalityBlobs)
if errors.Is(err, ustore.StatusAlreadyExists) {
	fmt.Println(err)
}
fmt.Println(ustore.VersionName()) // the library the program runs against, such as "1.0.0-rc.1"

API

StructErrorError is one failed call: a status every caller can branch on, and the detail the status cannot carry.2
types.go:153 ↗
type Error struct {
    Status  Status
    Message string
}

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

ErrorError implements the error interface.
types.go:159 ↗
func (failure *Error) Error() string
UnwrapUnwrap exposes the status, which is what errors.Is compares.
types.go:164 ↗
func (failure *Error) Unwrap() error
EnumStatusStatus names what went wrong, in a vocabulary shared by every engine and by this binding.3
types.go:83 ↗
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 matches any failure carrying it against a bare Status.

Values

StatusSuccessStatusSuccess means the call succeeded and carries no message.
StatusDeferredStatusDeferred means the call was submitted deferred and is not final yet.
StatusOutOfMemoryStatusOutOfMemory means an allocation could not be satisfied.
StatusReadOnlyStatusReadOnly means the call would change a database opened read-only.
StatusIOStatusIO means a file or directory could not be opened, read, written, or closed.
StatusDeviceStatusDevice means a device could not be selected or its memory claimed, or the call's executor, database and arena belong to different residencies or devices.
StatusMalformedStatusMalformed means stored or supplied data could not be decoded.
StatusInternalStatusInternal means the engine failed in a way no other status names.
StatusOverflowStatusOverflow means a count passed what its word holds, like the open exports of one arena.
StatusUninitializedStatusUninitialized means the call needs a handle that was never opened or is closed.
StatusConfigMismatchStatusConfigMismatch means the handles or arguments are each well-formed but cannot be joined.
StatusContendedStatusContended means the call was refused rather than waited for: another call holds its executor, arena, cursor or transaction.
StatusCancelledStatusCancelled means a progress handler stopped the call, which unwound and published nothing.
StatusUnsupportedStatusUnsupported means the engine or build does not implement what the call asks for.
StatusInvalidArgumentStatusInvalidArgument means an argument is missing, contradicts another one, or carries a choice the call does not accept.
StatusNotFoundStatusNotFound means a collection, a directory, or a document a modification needs does not exist.
StatusAlreadyExistsStatusAlreadyExists means a collection name or a document the call creates is already taken.
StatusWriteConflictStatusWriteConflict means a concurrent writer changed a key this transaction wrote.
StatusReadConflictStatusReadConflict means a concurrent writer changed a key this transaction read.
StatusPhantomConflictStatusPhantomConflict means a concurrent writer inserted into a range this transaction scanned.
StatusCapacityExhaustedStatusCapacityExhausted means a hard design ceiling was reached.
StatusFromNameStatusFromName reads a status back from the spelling Status.String renders.
types.go:142 ↗
func StatusFromName(name string) (Status, error)
ErrorError implements the error interface, so a bare Status is an errors.Is target.
types.go:149 ↗
func (status Status) Error() string
StringString renders the status as the library spells it, such as "not-found".
types.go:137 ↗
func (status Status) String() string