[go: up one dir, main page]

caps/
errors.rs

1//! Error handling.
2
3/// Library errors.
4#[derive(Debug)]
5pub struct CapsError(pub(crate) String);
6
7impl From<&str> for CapsError {
8    fn from(arg: &str) -> Self {
9        Self(arg.to_string())
10    }
11}
12
13impl From<String> for CapsError {
14    fn from(arg: String) -> Self {
15        Self(arg)
16    }
17}
18
19impl std::error::Error for CapsError {}
20
21impl std::fmt::Display for CapsError {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        write!(f, "caps error: {}", self.0)
24    }
25}