1use std::fmt;
2use std::error::Error;
3
4pub enum CriusError {
7 ExecutionRejected,
9
10 InvalidConfig,
13}
14
15const REJECTED: &str = "Rejected command execution due to open breaker";
16const INVALID: &str = "Provided circuit breaker configuration was invalid";
17
18impl fmt::Display for CriusError {
19 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
20 match *self {
21 CriusError::ExecutionRejected => write!(f, "{}", REJECTED),
22 CriusError::InvalidConfig => write!(f, "{}", INVALID),
23 }
24 }
25}
26
27impl fmt::Debug for CriusError {
28 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29 <Self as fmt::Display>::fmt(self, f)
30 }
31}
32
33impl Error for CriusError {
34 fn description(&self) -> &str {
35 match *self {
36 CriusError::ExecutionRejected => REJECTED,
37 CriusError::InvalidConfig => INVALID,
38 }
39 }
40}