Skip to main content

matrix_rain/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum MatrixError {
5    #[error("invalid configuration: {0}")]
6    InvalidConfig(String),
7    #[error("empty character set")]
8    EmptyCharset,
9}
10
11#[cfg(test)]
12mod tests {
13    use super::*;
14
15    #[test]
16    fn invalid_config_renders_message() {
17        let e = MatrixError::InvalidConfig("fps must be >= 1".into());
18        assert_eq!(e.to_string(), "invalid configuration: fps must be >= 1");
19    }
20
21    #[test]
22    fn empty_charset_renders_message() {
23        assert_eq!(MatrixError::EmptyCharset.to_string(), "empty character set");
24    }
25}