ddmw_util/
err.rs

1use std::fmt;
2
3#[derive(Debug)]
4pub enum Error {
5  BadFormat(String),
6  Figment(String),
7  FileNotFound(String),
8  SerializeError(String)
9}
10
11impl std::error::Error for Error {}
12
13impl fmt::Display for Error {
14  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15    match &*self {
16      Error::BadFormat(s) => {
17        write!(f, "Bad format; {}", s)
18      }
19      Error::Figment(s) => {
20        write!(f, "Figiment error; {}", s)
21      }
22      Error::FileNotFound(s) => {
23        write!(f, "File not found; {}", s)
24      }
25      Error::SerializeError(s) => {
26        write!(f, "Unable to serialize; {}", s)
27      }
28    }
29  }
30}
31
32impl From<figment::Error> for Error {
33  fn from(err: figment::Error) -> Self {
34    Error::Figment(err.to_string())
35  }
36}
37
38// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :