Skip to main content

app_json_settings/core/
error.rs

1use std::io;
2
3//
4// Error
5//
6#[derive(Debug)]
7pub enum ConfigError {
8    Io(io::Error),
9    Serialize(serde_json::Error),
10    Deserialize(serde_json::Error),
11}
12
13impl From<io::Error> for ConfigError {
14    fn from(e: io::Error) -> Self {
15        ConfigError::Io(e)
16    }
17}
18
19impl From<serde_json::Error> for ConfigError {
20    fn from(e: serde_json::Error) -> Self {
21        if e.is_data() || e.is_syntax() {
22            ConfigError::Deserialize(e)
23        } else {
24            ConfigError::Serialize(e)
25        }
26    }
27}
28
29pub type Result<T> = std::result::Result<T, ConfigError>;