1use std::fmt::{Display, Formatter, Result};
2
3#[derive(Debug, Clone)]
4pub enum MbtError {
5 NotImplemented(String),
6 Other(String),
7}
8
9impl MbtError {
10 pub fn other<S: Into<String>>(message: S) -> MbtError {
11 MbtError::Other(message.into())
12 }
13
14 pub fn not_implemented<S: Into<String>>(message: S) -> MbtError {
15 MbtError::NotImplemented(message.into())
16 }
17
18 pub fn from_err<E: std::error::Error>(error: E) -> MbtError {
19 MbtError::Other(format!("{}", error))
20 }
21
22 pub fn is_not_implemented(&self) -> bool {
23 match self {
24 MbtError::NotImplemented(_) => true,
25 _ => false
26 }
27 }
28}
29
30impl Display for MbtError {
31 fn fmt(&self, f: &mut Formatter) -> Result {
32 match self {
33 MbtError::NotImplemented(s) => write!(f, "Not Implemented: {}", s),
34 MbtError::Other(s) => write!(f, "Execution Error: {}", s),
35 }
36 }
37}
38
39impl std::error::Error for MbtError {}