1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use std::fmt::Formatter;
use std::fmt::Error as StdError;
pub enum Error {
NoneError,
OutOfBounds,
ExternalError(String)
}
impl std::error::Error for Error {}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), StdError> {
write!(f, "{}", self.to_string())
}
}
impl std::fmt::Debug for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), StdError> {
(self as &dyn std::fmt::Display).fmt(f)
}
}
impl std::convert::From<regex::Error> for Error {
fn from(e : regex::Error) -> Self {
Error::ExternalError(e.to_string())
}
}
impl std::convert::From<std::io::Error> for Error {
fn from(e : std::io::Error) -> Self {
Error::ExternalError(e.to_string())
}
}