Skip to main content

aex_core/
error.rs

1use thiserror::Error;
2
3/// Top-level error type for the Agent Exchange Protocol (AEX) core.
4///
5/// Each variant names a specific failure mode. We avoid catch-all variants
6/// (`StandardError`, `anyhow::Error`) because the control plane needs to
7/// map errors to HTTP responses, audit events, and user-facing messages —
8/// and those mappings depend on knowing exactly what went wrong.
9#[derive(Debug, Error)]
10pub enum Error {
11    #[error("invalid agent_id: {0}")]
12    InvalidAgentId(String),
13
14    #[error("unknown identity scheme")]
15    UnknownIdentityScheme,
16
17    #[error("signature verification failed")]
18    SignatureInvalid,
19
20    #[error("signature format invalid: {0}")]
21    SignatureFormat(String),
22
23    #[error("key unavailable: {0}")]
24    KeyUnavailable(String),
25
26    #[error("not found: {0}")]
27    NotFound(String),
28
29    #[error("I/O error: {0}")]
30    Io(#[from] std::io::Error),
31
32    #[error("crypto error: {0}")]
33    Crypto(String),
34
35    #[error("internal error: {0}")]
36    Internal(String),
37}
38
39pub type Result<T> = std::result::Result<T, Error>;