type Error struct {
Status Status
Message string
} Reach the status with errors.Is or errors.As.
Ask your coding agent about this page, or add the docs server to it
curl -s 'https://www.unum.cloud/docs/ucall/go/errors.md' | claude -p "How would this fit my code?"Every fallible call answers an error, an *ucall.Error carrying the Status the library reported and its static message, which errors.Is matches against a bare Status.
A mistake the binding catches before calling the library, like a client closed before a call, reports the status the library would have used. Status prints its stable spelling, such as “connection-failed”.
client, err := ucall.NewClient(&ucall.ClientOptions{Connections: 1})
if err != nil {
return err
}
defer client.Close()
response, err := client.Get("http://127.0.0.1:1/")
switch {
case errors.Is(err, ucall.StatusConnectionFailed):
fmt.Println("nobody listens:", err)
case err != nil:
return err
default:
defer response.Close()
fmt.Println("answered", response.StatusCode())
}A submitted call that fails completes with Completed.Err: StatusConnectionFailed, StatusConnectionClosed, StatusTimeout, StatusHandshakeFailed or StatusPeerRejected.
A request or response lookup that finds nothing fails with StatusNotFound beside an empty value, and HTTP error statuses are ordinary responses. Backend, CPUClass and Status print their stable names, like “linux-uring618” and “intel-icelake”, and BackendFromName, CPUClassFromName and StatusFromName parse them back, failing with StatusInvalidArgument on a name no value has. ucall.Version() spells the linked library’s version, candidate suffix included, and ucall.DecodePercent decodes a path or a query value, which requests hold still percent-encoded.
ErrorError is one failed call: a status every caller can branch on, and the detail the status cannot carry.2type Error struct {
Status Status
Message string
} Reach the status with errors.Is or errors.As.
ErrorError implements the error interface.func (failure *Error) Error() string UnwrapUnwrap exposes the status, which is what errors.Is compares.func (failure *Error) Unwrap() error StatusStatus names what went wrong, in a vocabulary shared by the library and by this binding.3type Status int32 Validation performed here before a call crosses reports the status the library would have reported for the same fault.
A Status is an error, so errors.Is(err, ucall.StatusConnectionFailed) matches any failure carrying it.
StatusSuccess | StatusSuccess means the call completed and carries no message. | |
|---|---|---|
StatusDeferred | StatusDeferred means a submitted call is not final yet. | |
StatusOutOfMemory | StatusOutOfMemory means an allocation or reservation could not be satisfied. | |
StatusIO | StatusIO means a socket or file could not be opened, read, written or closed. | |
StatusMalformed | StatusMalformed means the peer sent bytes that do not decode as the expected protocol. | |
StatusInternal | StatusInternal means the library violated its contract, which points at a defect. | |
StatusOverflow | StatusOverflow means a size exceeds the representable range. | |
StatusUninitialized | StatusUninitialized means the call needs a handle that was never made or is closed. | |
StatusContended | StatusContended means the call was refused rather than waited for. | |
StatusUnsupported | StatusUnsupported means the build, backend or machine lacks the feature. | |
StatusInvalidArgument | StatusInvalidArgument means an argument is missing, out of range or contradicts another. | |
StatusNotFound | StatusNotFound means the endpoint, header or parameter does not exist. | |
StatusAlreadyExists | StatusAlreadyExists means an endpoint of the same template and verb is registered, or a request was already answered. | |
StatusConnectionFailed | StatusConnectionFailed means a lookup or a connection attempt failed. | |
StatusConnectionClosed | StatusConnectionClosed means the connection closed before the exchange completed. | |
StatusTimeout | StatusTimeout means the operation exceeded its time budget. | |
StatusHandshakeFailed | StatusHandshakeFailed means the Noise handshake failed to authenticate or agree on keys. | |
StatusPeerRejected | StatusPeerRejected means the peer authorizer declined the authenticated static key. | |
StatusWouldBlock | StatusWouldBlock means a nonblocking poll or pull had no progress to report. |
StatusFromNameStatusFromName reads a status back from the spelling String gives it.func StatusFromName(name string) (Status, error) ErrorError implements the error interface, so a bare Status is an errors.Is target.func (status Status) Error() string StringString renders the status as the library spells it, such as "connection-failed".func (status Status) String() string