Skip to main content

bus_core/
error.rs

1use thiserror::Error;
2
3/// Errors returned by handler implementations.
4#[derive(Debug, Error)]
5pub enum HandlerError {
6    /// Transient failure: the message should be retried.
7    #[error("transient: {0}")]
8    Transient(String),
9
10    /// Permanent failure: the message should not be retried.
11    #[error("permanent: {0}")]
12    Permanent(String),
13}
14
15/// Top-level error type for event bus operations.
16#[derive(Debug, Error)]
17pub enum BusError {
18    #[error("nats: {0}")]
19    Nats(String),
20
21    #[error("publish: {0}")]
22    Publish(String),
23
24    #[error("outbox: {0}")]
25    Outbox(String),
26
27    #[error("idempotency: {0}")]
28    Idempotency(String),
29
30    #[error("serialization: {0}")]
31    Serde(#[from] serde_json::Error),
32
33    #[error("handler: {0}")]
34    Handler(#[from] HandlerError),
35
36    #[error("nats unavailable")]
37    NatsUnavailable,
38}