television_previewers/ansi/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/// This enum stores the error types
#[derive(Debug, thiserror::Error, PartialEq)]
pub enum Error {
    /// Stack is empty (should never happen)
    #[error("Internal error: stack is empty")]
    NomError(String),

    /// Error parsing the input as utf-8
    #[cfg(feature = "simd")]
    /// Cannot determine the foreground or background
    #[error("{0:?}")]
    Utf8Error(#[from] simdutf8::basic::Utf8Error),

    #[cfg(not(feature = "simd"))]
    /// Cannot determine the foreground or background
    #[error("{0:?}")]
    Utf8Error(#[from] std::string::FromUtf8Error),
}

impl From<nom::Err<nom::error::Error<&[u8]>>> for Error {
    fn from(e: nom::Err<nom::error::Error<&[u8]>>) -> Self {
        Self::NomError(format!("{:?}", e))
    }
}