1use std::error;
2use std::fmt;
3
4#[derive(Debug)]
6pub enum Error {
7 TooManyStates(usize),
12}
13
14impl fmt::Display for Error {
15 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16 use self::Error::*;
17 match *self {
18 TooManyStates(size_limit) => write!(
19 f,
20 "Levenshtein automaton exceeds size limit of \
21 {} states",
22 size_limit
23 ),
24 }
25 }
26}
27
28impl error::Error for Error {
29 fn description(&self) -> &str {
30 use self::Error::*;
31 match *self {
32 TooManyStates(_) => "levenshtein automaton has too many states",
33 }
34 }
35
36 fn cause(&self) -> Option<&dyn error::Error> {
37 None
38 }
39}