1use std::fmt;
2
3#[derive(Debug)]
4pub enum CustomError {
5 WrongArg,
6 InvalidFormat,
7 Other
8}
9
10impl fmt::Display for CustomError {
11 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12 match self {
13 CustomError::WrongArg => {
14 write!(f, "{}", "Wrong arguments")
15 },
16 _ => {
17 write!(f, "{}", "Other")
18 },
19 }
20 }
21}
22
23impl std::error::Error for CustomError {
24 fn description(&self) -> &str {
25 match self {
26 CustomError::WrongArg => {
27 "Wrong arguments"
28 },
29 _ => {
30 "Other"
31 }
32 }
33 }
34}