1use snafu::Snafu;
15use tibba_error::Error as BaseError;
16
17mod app_config;
18
19#[derive(Debug, Snafu)]
21pub enum Error {
22 #[snafu(display("{category}, url parse error {source}"))]
23 Url {
24 category: String,
25 source: url::ParseError,
26 },
27 #[snafu(display("{category}, config error {source}"))]
28 Config {
29 category: String,
30 source: config::ConfigError,
31 },
32 #[snafu(display("{category}, parse duration error {source}"))]
33 ParseDuration {
34 category: String,
35 source: humantime::DurationError,
36 },
37}
38
39impl From<Error> for BaseError {
40 fn from(val: Error) -> Self {
41 let (category, err) = match val {
42 Error::Url { category, source } => (category, source.to_string()),
43 Error::Config { category, source } => (category, source.to_string()),
44 Error::ParseDuration { category, source } => (category, source.to_string()),
45 };
46
47 BaseError::new(err)
48 .with_sub_category(&category)
49 .with_category("config")
50 .with_exception(true)
51 }
52}
53
54pub use app_config::*;