shadow_terminal/
errors.rs

1//! Errors for this library
2//
3// TODO: This is my first use of Snafu, there seems like a lot of `Whatever` boilerplate?
4
5/// All the known errors returned by this crate.
6#[derive(Debug, snafu::Snafu)]
7#[non_exhaustive]
8pub enum ShadowTerminalError {
9    #[snafu(display("PTY Error"))]
10    /// Any error that occurs in the PTY
11    PTY {
12        /// The parent error type
13        source: PTYError,
14    },
15
16    #[snafu(display("SteppableTerminal Error"))]
17    /// Any error that occurs in the PTY
18    SteppableTerminal {
19        /// The parent error type
20        source: SteppableTerminalError,
21    },
22
23    /// General errors that don't need to be matched on
24    #[snafu(whatever, display("{message}"))]
25    Whatever {
26        /// A helpful message acompanying the error
27        message: String,
28        /// The parent error type
29        #[snafu(source(from(Box<dyn std::error::Error + Send + Sync>, Some)))]
30        source: Option<Box<dyn std::error::Error + Send + Sync>>,
31    },
32}
33
34/// An error in the PTY.
35#[derive(Debug, snafu::Snafu)]
36#[non_exhaustive]
37pub enum PTYError {
38    /// General errors that don't need to be matched on
39    #[snafu(whatever, display("{message}"))]
40    Whatever {
41        /// A helpful message acompanying the error
42        message: String,
43        /// The parent error type
44        #[snafu(source(from(Box<dyn std::error::Error + Send + Sync>, Some)))]
45        source: Option<Box<dyn std::error::Error + Send + Sync>>,
46    },
47}
48
49/// An error in the Steppable terminal.
50#[derive(Debug, snafu::Snafu)]
51#[non_exhaustive]
52pub enum SteppableTerminalError {
53    /// General errors that don't need to be matched on
54    #[snafu(whatever, display("{message}"))]
55    Whatever {
56        /// A helpful message acompanying the error
57        message: String,
58        /// The parent error type
59        #[snafu(source(from(Box<dyn std::error::Error + Send + Sync>, Some)))]
60        source: Option<Box<dyn std::error::Error + Send + Sync>>,
61    },
62}