elvis_core/err.rs
1//! Elvis shared errors
2/// Elvis shared errors
3#[derive(Debug)]
4pub enum Error {
5 /// Function Error
6 FunctionError(String),
7 /// Deserialize Error
8 DeserializeHtmlError(String),
9 /// Router Error
10 RouterError(String),
11 /// Custom Error
12 Custom(String),
13}
14
15impl Error {
16 /// Check derive errors
17 pub fn check<T, E, IE>(r: &Result<T, IE>) -> Result<(), Error>
18 where
19 E: Into<Error> + From<IE>,
20 IE: Clone,
21 {
22 if let Err(e) = r {
23 Err(E::from(e.clone()).into())
24 } else {
25 Ok(())
26 }
27 }
28}