Skip to main content

ClientError

Enum ClientError 

Source
#[non_exhaustive]
pub enum ClientError { Io(Error), Nack(NackReason), VersionMismatch { daemon_version: u8, }, UnknownNack(u8), PayloadTooLarge { len: usize, limit: usize, }, Protocol(String), NoDefaultDurability, EmptyPayload, }
Expand description

All errors that can be returned by WeirClient methods.

#[non_exhaustive]: the client error set may grow post-1.0 (it already gained VersionMismatch during the 1.0 hardening), so downstream matches must carry a wildcard arm and adding a variant later is not a breaking change.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Io(Error)

An I/O error on the underlying socket.

§

Nack(NackReason)

The daemon sent a Nack with a recognised reason.

§

VersionMismatch

The daemon rejected the frame because its wire version differs from the client’s. Carries the daemon’s WIRE_VERSION (the second Nack-payload byte) so the caller can report both sides and decide whether to upgrade the daemon or downgrade the client.

Fields

§daemon_version: u8

The wire-protocol version the daemon speaks.

§

UnknownNack(u8)

The daemon sent a Nack with an unrecognised reason byte.

§

PayloadTooLarge

The payload exceeds the protocol hard cap and was rejected locally, before any bytes were sent. The daemon would always reject a payload this large (and a large frame can race the daemon’s Nack-and-close, surfacing as a bare broken-pipe), so the client rejects it up front with no round-trip. A deployment’s configured max_payload_bytes may be lower than this cap; a payload over that lower limit is reported by the daemon as ClientError::Nack(NackReason::PayloadTooLarge).

Fields

§len: usize

The rejected payload’s length in bytes.

§limit: usize

The protocol hard cap (weir_core::MAX_PAYLOAD_HARD_CAP).

§

Protocol(String)

The daemon’s response violated the wire protocol.

§

NoDefaultDurability

push_default was called but no default durability was set.

§

EmptyPayload

push was called with an empty payload, rejected locally before any bytes are sent. An empty payload IS the WAB end-of-records sentinel, so the daemon Nacks it (NackReason::EmptyPayload) and closes the connection; rejecting up front keeps the connection usable, mirroring the local PayloadTooLarge reject.

Implementations§

Source§

impl ClientError

Source

pub fn is_recoverable(&self) -> bool

Whether the connection is still usable after this error.

  • Recoverable (true) — the connection is still usable: the error is a local or per-record rejection that does not poison the client. Retry a different payload, or continue, on the same client.
  • Non-recoverable (false) — the connection is dead or in an indeterminate state: the error poisoned the client (set its internal poisoned/closed_after_nack flag). Drop this client and reconnect; every subsequent call on it will fail fast (see WeirClient::is_poisoned).

This is the stable way to branch on whether to reconnect: ClientError is #[non_exhaustive], so an exhaustive match on its variants will not compile downstream, and the variant set may grow post-1.0. Calling is_recoverable (or checking WeirClient::is_poisoned after a failed call) keeps working across additions.

The classification is kept in lock-step with the client’s poison logic: a variant is recoverable iff producing it does not set the client’s poisoned or closed_after_nack flag.

VariantRecoverable?Why
PayloadTooLargeyeslocal pre-send rejection; no bytes sent, connection untouched
EmptyPayloadyeslocal pre-send rejection; no bytes sent, connection untouched
NoDefaultDurabilityyeslocal misconfiguration; returned before any I/O
Nack(InternalError)yestransient daemon condition; the daemon keeps the connection open
Nack(any other reason)nothe daemon closes the connection after the Nack
VersionMismatchnoa Nack reason; the daemon closes the connection
UnknownNacknoa Nack reason; the daemon closes the connection
Ionoa socket read/write failure poisons the client
Protocolnoa malformed/aborted response poisons the client (also the “reconnect” guard error)

Note: a server Nack(PayloadTooLarge) (a payload over the daemon’s configured cap) is not recoverable — the daemon Nacks then closes the connection — whereas the local PayloadTooLarge error (a payload over the protocol hard cap, rejected before any bytes are sent) is. They are distinct variants despite the shared name.

New #[non_exhaustive] variants default to non-recoverable (false): “drop and reconnect” is the safe assumption for an error this build does not yet understand.

Trait Implementations§

Source§

impl Debug for ClientError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ClientError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ClientError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for ClientError

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.