1use std::fmt;
2
3pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug)]
8pub enum Error {
9 NotFound(String),
11 InvalidInput(String),
13 Runtime(agtrace_runtime::Error),
15}
16
17impl fmt::Display for Error {
18 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19 match self {
20 Error::NotFound(msg) => write!(f, "Not found: {}", msg),
21 Error::InvalidInput(msg) => write!(f, "Invalid input: {}", msg),
22 Error::Runtime(err) => write!(f, "{}", err),
23 }
24 }
25}
26
27impl std::error::Error for Error {
28 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
29 match self {
30 Error::Runtime(err) => Some(err),
31 _ => None,
32 }
33 }
34}
35
36impl From<agtrace_runtime::Error> for Error {
37 fn from(err: agtrace_runtime::Error) -> Self {
38 Error::Runtime(err)
39 }
40}