1use std::fmt;
2
3#[derive(Debug, Clone, Eq, PartialEq)]
4pub enum ArgotError {
5 InvalidInt(String),
6 NullArg(String),
7 NullInt(String),
8 ConfigsNotFound,
9 TargetNotFound(String),
10 Alias2Alias,
11 TypeNotSupported(String),
12 OptionNotSupported(String),
13 EmptyList,
14 Generic(String),
15}
16
17impl fmt::Display for ArgotError {
18 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19 match self {
20 ArgotError::InvalidInt(value) =>
21 write!(f, "'{}' is not a valid number", value),
22 ArgotError::NullArg(name) =>
23 write!(f, "option '{}' must take an argument", name),
24 ArgotError::NullInt(name) =>
25 write!(f, "option '{}' requires a numeric argument", name),
26 ArgotError::ConfigsNotFound =>
27 write!(f, "no configuration options were found"),
28 ArgotError::TargetNotFound(name) =>
29 write!(f, "alias target '{}' was not found", name),
30 ArgotError::Alias2Alias =>
31 write!(f, "cannot create an alias to another alias"),
32 ArgotError::TypeNotSupported(name) =>
33 write!(f, "type '{}' is not supported", name),
34 ArgotError::OptionNotSupported(name) =>
35 write!(f, "option '{}' is not supported", name),
36 ArgotError::EmptyList =>
37 write!(f, "arg_list cannot be empty"),
38 ArgotError::Generic(msg) => write!(f, "{}", msg),
39 }
40 }
41}
42
43impl std::error::Error for ArgotError {}