Each major crate defines its own thiserror-derived error enum.
Cross-crate propagation uses explicit From impls or .map_err().
13 variants covering crypto, network, agent, task, identity, and serialization failures. Used by all downstream crates.
NexusError
├── EncryptionError(String)
├── DecryptionError(String)
├── SerializationError(serde_json::Error) ← From<serde_json::Error>
├── NetworkError(String) ← From<std::io::Error>
├── InvalidMessage(String)
├── AgentError(String)
├── TaskExecutionError(String)
├── ConfigurationError(String)
├── UnknownTechnique(String)
├── InvalidIdentity(String)
├── SignatureVerificationFailed
├── CryptoFailure(String)
└── BincodeError(String)
10 variants for infrastructure operations. Does not implement
From<NexusError> — the two hierarchies are kept separate to avoid
blanket conversions that lose context.
InfraError
├── ConfigError(String)
├── CloudflareError(String)
├── CertificateError(String)
├── LetsEncryptError(String)
├── DomainError(String)
├── GrpcError(String)
├── NetworkError(reqwest::Error) ← From<reqwest::Error>
├── TlsError(String)
├── IoError(String) ← From<std::io::Error>
└── BofError(String)
Each module defines its own error type to keep boundaries tight:
| Error | Module | Variants |
|---|---|---|
CardError |
cards.rs |
Parse, Verify, Serialize |
TokenError |
tokens.rs |
Expired, InvalidSignature, Malformed |
TlsError |
tls.rs |
CertLoad, KeyLoad, KeyMismatch |
CapabilityError |
capabilities.rs |
Denied, InvalidMatrix |
S3SinkError |
audit_s3.rs |
Upload, Config, FeatureDisabled |
OtelError |
otel.rs |
Init, FeatureDisabled |
Covers DTN queue I/O failures. Implements From<std::io::Error>.
std::io::Error ──► NexusError::NetworkError
std::io::Error ──► InfraError::IoError
std::io::Error ──► DtnError::Io
serde_json::Error ──► NexusError::SerializationError
reqwest::Error ──► InfraError::NetworkError
No cross-crate From impls exist. This is intentional — it forces
callers to explicitly map errors at crate boundaries, preserving
context.
- Library crates (
nexus-common,nexus-a2a,nexus-mesh): usethiserrorenums. ReturnResult<T, SpecificError>. - Binary boundaries (
nexus-server,nexus-agent): useanyhowfor top-level error propagation. Convert typed errors via?. - Cross-crate propagation: use
.map_err()to wrap the source error with context:nexus_a2a::tls::load_server_config() .map_err(|e| InfraError::TlsError(format!("A2A TLS: {e}")))?;