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:

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. code is the first word of the reply, such as ERR, WRONGPASS or BACKPRESSURE; reply is 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

  • ConnectionClosed

    The connection was closed, by close or after an earlier failure.

  • DeadlineExceeded

    The request’s deadline passed while it waited for earlier requests on the same connection. It is discarded, never sent later.

  • UnsolicitedData

    The 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

  • Timeout

    No complete reply arrived before the deadline.

  • PeerClosed

    The server closed the connection before replying in full.

  • TransportFailed(String)
  • MalformedReply(resp_codec.DecodeError)

    The reply is not valid RESP.

  • TrailingData

    More than one reply arrived for a single request.

  • ReplyTooLarge

    The 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.

✨ Search Document