Skip to main content

helios_subscriptions/
error.rs

1//! Subscription error types.
2
3use thiserror::Error;
4
5/// Errors that can occur during subscription operations.
6#[derive(Debug, Error)]
7pub enum SubscriptionError {
8    /// The referenced SubscriptionTopic was not found.
9    #[error("subscription topic not found: {url}")]
10    TopicNotFound { url: String },
11
12    /// A filter parameter is invalid or not supported by the topic.
13    #[error("invalid filter: {message}")]
14    InvalidFilter { message: String },
15
16    /// The requested channel type is not supported.
17    #[error("unsupported channel type: {channel_type}")]
18    UnsupportedChannel { channel_type: String },
19
20    /// The channel endpoint is invalid or missing.
21    #[error("invalid channel endpoint: {message}")]
22    InvalidEndpoint { message: String },
23
24    /// Notification delivery failed.
25    #[error("delivery failed: {message}")]
26    DeliveryFailed { message: String },
27
28    /// An invalid subscription status transition was attempted.
29    #[error("invalid status transition from {from} to {to}")]
30    InvalidStatusTransition { from: String, to: String },
31
32    /// The subscription resource is malformed.
33    #[error("invalid subscription resource: {message}")]
34    InvalidSubscription { message: String },
35
36    /// An error occurred in the persistence layer.
37    #[error("storage error: {0}")]
38    Storage(String),
39
40    /// An internal error occurred.
41    #[error("internal error: {0}")]
42    Internal(String),
43}
44
45impl From<helios_persistence::error::StorageError> for SubscriptionError {
46    fn from(e: helios_persistence::error::StorageError) -> Self {
47        Self::Storage(e.to_string())
48    }
49}
50
51impl From<helios_auth::AuthError> for SubscriptionError {
52    fn from(e: helios_auth::AuthError) -> Self {
53        Self::DeliveryFailed {
54            message: format!("outbound auth failed: {e}"),
55        }
56    }
57}