1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use std::error;
use std::fmt;
use std::result::Result;
#[allow(missing_docs)]
#[rustversion::attr(since(1.40), non_exhaustive)]
#[derive(Debug, Clone)]
pub enum ValidateError {
Oops(String),
}
impl fmt::Display for ValidateError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ValidateError::Oops(msg) => write!(f, "Oops! {}", msg),
}
}
}
impl error::Error for ValidateError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
None
}
}
pub(crate) fn make_oops<T, S: Into<String>>(msg: S) -> Result<T, ValidateError> {
Err(ValidateError::Oops(msg.into()))
}
pub type ValidateResult = Result<(), ValidateError>;