1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum Error {
8 #[error("NATS error: {0}")]
10 Nats(#[from] async_nats::Error),
11
12 #[error("Connection error: {0}")]
14 Connect(#[from] async_nats::ConnectError),
15
16 #[error("Publish error: {0}")]
18 Publish(#[from] async_nats::PublishError),
19
20 #[error("Subscribe error: {0}")]
22 Subscribe(#[from] async_nats::SubscribeError),
23
24 #[cfg(feature = "msgpack")]
26 #[error("MessagePack serialization error: {0}")]
27 MsgPackSerialize(#[from] rmp_serde::encode::Error),
28
29 #[cfg(feature = "msgpack")]
31 #[error("MessagePack deserialization error: {0}")]
32 MsgPackDeserialize(#[from] rmp_serde::decode::Error),
33
34 #[cfg(feature = "json")]
36 #[error("JSON error: {0}")]
37 Json(#[from] serde_json::Error),
38
39 #[error("JetStream error: {0}")]
41 JetStream(String),
42
43 #[error("JetStream context error: {0}")]
45 JetStreamContext(#[from] async_nats::jetstream::context::CreateStreamError),
46
47 #[error("JetStream consumer error: {0}")]
49 JetStreamConsumer(String),
50
51 #[error("JetStream stream error: {0}")]
53 JetStreamStream(String),
54
55 #[error("Request error: {0}")]
57 Request(#[from] async_nats::RequestError),
58
59 #[error("Timeout")]
61 Timeout,
62
63 #[error("Subscriber closed")]
65 SubscriberClosed,
66
67 #[error("Publisher closed")]
69 PublisherClosed,
70
71 #[error("Invalid configuration: {0}")]
73 InvalidConfig(String),
74}
75
76pub type Result<T> = std::result::Result<T, Error>;