1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
use derive_more::{Display, From};

// TODO: SourceNotFound should contain selector info
#[derive(Display, Debug, From)]
pub enum Error {
    #[display(fmt = "source not found")]
    SourceNotFound,
    #[display(fmt = "attr(`{}`) is not found in `{}`", attr, src)]
    AttrNotFound { attr: String, src: String },
    #[display(fmt = "{} cannot be parsed as {}: {}", text, type_name, err)]
    TextParseError {
        text: String,
        type_name: String,
        err: String,
    },
}

impl std::error::Error for Error {}

pub type Result<T> = std::result::Result<T, Error>;