television_previewers/ansi/
error.rs

1/// This enum stores the error types
2#[derive(Debug, thiserror::Error, PartialEq)]
3pub enum Error {
4    /// Stack is empty (should never happen)
5    #[error("Internal error: stack is empty")]
6    NomError(String),
7
8    /// Error parsing the input as utf-8
9    #[cfg(feature = "simd")]
10    /// Cannot determine the foreground or background
11    #[error("{0:?}")]
12    Utf8Error(#[from] simdutf8::basic::Utf8Error),
13
14    #[cfg(not(feature = "simd"))]
15    /// Cannot determine the foreground or background
16    #[error("{0:?}")]
17    Utf8Error(#[from] std::string::FromUtf8Error),
18}
19
20impl From<nom::Err<nom::error::Error<&[u8]>>> for Error {
21    fn from(e: nom::Err<nom::error::Error<&[u8]>>) -> Self {
22        Self::NomError(format!("{:?}", e))
23    }
24}