1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//! Custom errors for mac-notification-sys.
use failure;
/// Custom Result type for mac-notification-sys.
pub type NotificationResult<T> = Result<T, failure::Error>;

/// Errors that can occur setting the Bundle Identifier.
#[derive(Debug, Fail)]
pub enum ApplicationError {
    /// The application name is already set.
    #[fail(display = "Application can only be set once.")]
    AlreadySet,
    /// The application name could not be set.
    #[fail(display = "Could not set application, using default \"com.apple.Termial\"")]
    CouldNotSet,
}

/// Errors that can occur while interacting with the NSUserNotificationCenter.
#[derive(Debug, Fail)]
pub enum NotificationError {
    /// Notifications can not be scheduled in the past.
    #[fail(display = "Can not schedule notification in the past")]
    ScheduleInThePast,
    /// Schedule a notification caused an error.
    #[fail(display = "Could not schedule notification")]
    UnableToSchedule,
    /// Deliver a notification caused an error.
    #[fail(display = "Could not deliver notification")]
    UnableToDeliver,
}