agtrace_sdk/
error.rs

1use std::fmt;
2
3/// Result type alias for SDK operations.
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// Error type for SDK operations.
7#[derive(Debug)]
8pub enum Error {
9    /// Resource not found (session, project, etc.).
10    NotFound(String),
11    /// Invalid input parameters or configuration.
12    InvalidInput(String),
13    /// Error from the underlying runtime layer.
14    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}