ruststream_nats/error.rs
1//! Error type returned by NATS broker operations.
2
3use std::error::Error as StdError;
4
5use thiserror::Error;
6
7/// Errors surfaced by the NATS broker implementation.
8#[derive(Debug, Error)]
9#[non_exhaustive]
10pub enum NatsError {
11 /// Failed to establish or use the underlying `async-nats` connection.
12 #[error("nats connection error: {0}")]
13 Connect(#[source] Box<dyn StdError + Send + Sync>),
14
15 /// Failed to publish a message to the broker.
16 #[error("nats publish error: {0}")]
17 Publish(#[source] Box<dyn StdError + Send + Sync>),
18
19 /// Failed to subscribe to the requested subject.
20 #[error("nats subscribe error: {0}")]
21 Subscribe(#[source] Box<dyn StdError + Send + Sync>),
22
23 /// JetStream-specific operation failed (consumer creation, ack, etc.).
24 #[error("nats jetstream error: {0}")]
25 JetStream(#[source] Box<dyn StdError + Send + Sync>),
26
27 /// A request / reply operation timed out before a reply was received.
28 #[error("nats request timed out")]
29 RequestTimeout,
30
31 /// The supplied [`crate::SubscribeOptions`] combine fields in a way the broker cannot honour
32 /// (for example `durable(_)` without `jetstream(_)`, or `queue_group(_)` together with
33 /// `jetstream(_)`).
34 #[error("invalid subscribe options: {0}")]
35 InvalidOptions(String),
36}