Skip to main content

allow_core/
error.rs

1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
4pub struct CargoAllowError {
5    message: String,
6}
7
8impl CargoAllowError {
9    pub fn new(message: impl Into<String>) -> Self {
10        Self {
11            message: message.into(),
12        }
13    }
14}
15
16impl fmt::Display for CargoAllowError {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        write!(f, "{}", self.message)
19    }
20}
21
22impl std::error::Error for CargoAllowError {}
23
24pub type CargoAllowResult<T> = Result<T, CargoAllowError>;
25
26#[cfg(test)]
27#[path = "error_tests.rs"]
28mod tests;