Skip to main content

larastvel_core/notifications/
error.rs

1use thiserror::Error;
2
3use super::types::NotificationChannel;
4
5/// Errors that can occur during notification delivery.
6#[derive(Debug, Error)]
7pub enum NotificationError {
8    /// The channel is not supported by the notification.
9    #[error("Channel {0} is not supported by this notification")]
10    ChannelNotSupported(String),
11
12    /// The channel is not configured on the sender.
13    #[error("Channel {0} is not configured on the sender")]
14    ChannelNotConfigured(String),
15
16    /// The recipient did not provide the required route for a channel.
17    #[error("Invalid recipient: {0}")]
18    InvalidRecipient(String),
19
20    /// Mail delivery failed.
21    #[error(transparent)]
22    Mail(#[from] crate::mail::MailError),
23
24    /// Broadcast delivery failed.
25    #[error(transparent)]
26    Broadcast(#[from] crate::broadcasting::BroadcastError),
27
28    /// Database storage failed.
29    #[error("Database error: {0}")]
30    Database(String),
31
32    /// Webhook delivery failed.
33    #[error("Webhook error: {0}")]
34    Webhook(String),
35
36    /// SMS delivery failed.
37    #[error(transparent)]
38    Sms(#[from] crate::sms::SmsError),
39
40    /// Some channels succeeded but others failed.
41    #[error("Partial delivery: {0:?}")]
42    PartialDelivery(Vec<(NotificationChannel, NotificationError)>),
43}