skeg_client/error
Errors returned by skeg_client/connection and the commands built on it.
What an error proves about the request decides what the caller may do next:
ConnectFailed,InvalidArgumentandNotSent: no byte of the request reached the server, so nothing was applied.nothing_appliedis true only here.ServerError: the server answered with an error. It may have applied part of the request before failing.OutcomeUnknown: no complete answer arrived. The request may have been applied in full, in part, or not at all.
Send a write again only when nothing_applied is true, or after reading
back what the server holds.
Types
pub type Error {
ConnectFailed(reason: String)
InvalidArgument(reason: String)
ServerError(
code: String,
message: String,
reply: resp_codec.Value,
)
NotSent(reason: NotSentReason)
OutcomeUnknown(reason: UnknownReason)
UnexpectedReply(resp_codec.Value)
}
Constructors
-
ConnectFailed(reason: String)The TCP connection could not be opened.
-
InvalidArgument(reason: String)An argument cannot be sent as given, for example an id outside the unsigned 64-bit range. Nothing was sent.
-
ServerError( code: String, message: String, reply: resp_codec.Value, )The server answered with an error reply.
codeis the first word of the reply, such asERR,WRONGPASSorBACKPRESSURE;replyis the reply exactly as received. The connection stays usable. -
NotSent(reason: NotSentReason)The request was not sent. The connection stays usable only after
DeadlineExceeded. -
OutcomeUnknown(reason: UnknownReason)The request may have been applied. The connection is closed.
-
UnexpectedReply(resp_codec.Value)The server answered with a reply of a shape this command does not expect. The connection stays usable.
pub type NotSentReason {
ConnectionClosed
DeadlineExceeded
UnsolicitedData
}
Constructors
-
ConnectionClosedThe connection was closed, by
closeor after an earlier failure. -
DeadlineExceededThe request’s deadline passed while it waited for earlier requests on the same connection. It is discarded, never sent later.
-
UnsolicitedDataThe server sent bytes nobody asked for. The connection is closed, because those bytes could otherwise be taken as the next reply.
pub type UnknownReason {
Timeout
PeerClosed
TransportFailed(String)
MalformedReply(resp_codec.DecodeError)
TrailingData
ReplyTooLarge
}
Constructors
-
TimeoutNo complete reply arrived before the deadline.
-
PeerClosedThe server closed the connection before replying in full.
-
TransportFailed(String) -
MalformedReply(resp_codec.DecodeError)The reply is not valid RESP.
-
TrailingDataMore than one reply arrived for a single request.
-
ReplyTooLargeThe reply exceeds the connection’s
max_reply_bytes.
Values
pub fn from_reply(reply: resp_codec.Value) -> Result(Error, Nil)
The ServerError for an error reply (-... or !...), or Error(Nil)
for any other value.
pub fn is_temporary(error: Error) -> Bool
Whether the server described its refusal as temporary (BACKPRESSURE,
or RATELIMITED from a tenant backend), so the same request may succeed
later. This says nothing about effects already applied: combine it with
nothing_applied, or with a request that is safe to repeat.
pub fn nothing_applied(error: Error) -> Bool
Whether the error proves that the server applied nothing: the connection was never opened, or the request was rejected or dropped before sending.