noxious/
error.rs

1use thiserror::Error;
2
3/// Generic not found error
4#[derive(Error, Debug, Clone, Copy)]
5#[error("Item not found")]
6pub struct NotFoundError;
7
8/// Toxic update failed
9#[derive(Debug, Clone, Copy, Error, PartialEq)]
10pub enum ToxicUpdateError {
11    /// No such toxic with the given name
12    #[error("Toxic not found")]
13    NotFound,
14    /// Some other error
15    #[error("Other error")]
16    Other,
17}
18
19impl From<NotFoundError> for ToxicUpdateError {
20    fn from(_: NotFoundError) -> Self {
21        ToxicUpdateError::NotFound
22    }
23}
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28
29    #[test]
30    fn test_not_found() {
31        let input = NotFoundError;
32        let _err: ToxicUpdateError = input.into();
33    }
34}