ansi_to_html/
error.rs

1use std::num::ParseIntError;
2
3/// Errors that can occur when converting an ANSI string to HTML
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// Parsing a number was unsuccessful
7    #[error(transparent)]
8    ParseInt(#[from] ParseIntError),
9
10    /// The ANSI escape code is invalid
11    #[error("Invalid ANSI: {msg}")]
12    InvalidAnsi { msg: String },
13}
14
15impl Error {
16    pub(crate) fn invalid_ansi(s: &'static str) -> impl Fn() -> Self {
17        move || Error::InvalidAnsi { msg: s.to_string() }
18    }
19}