Expand description
Cross-service gRPC errors for Rust.
aerro gives every error a typed identity, a bounded call trace, and
a structured wire encoding. Derive Aerro on an error enum, call
IntoStatus to encode it into a tonic::Status, and TryFromStatus
on the client to recover the original variant — with the full chain of service
hops attached.
§Quick Example
use aerro::{Aerro, IntoStatus, StatusIntoResultExt};
#[derive(Debug, aerro::Aerro)]
pub enum CreateUserError {
#[aerro(category = Business, code = AlreadyExists, error = "email already taken: {email}")]
EmailTaken { email: String },
#[aerro(category = System, code = Internal, error = "db.unavailable")]
DbUnavailable,
}
// Server side
let err = CreateUserError::EmailTaken { email: "alice@example.com".into() };
let status = err.into_status_default();
// Client side — recover the typed variant
let recovered = status.into_aerro::<CreateUserError>().unwrap();§Feature Flags
| Flag | Default | Description |
|---|---|---|
macro | ✓ | Aerro derive macro |
tracing | ✗ | Capture OTel trace/span IDs via the tracing subscriber |
§Key Types
Aerro— the trait every error type implements (derive or manual)ServiceFailure<E>— typed error + frames + traceRemoteError— type-erased fallback for errors from unknown servicesFrame— one hop in the call chainTraceContext— OTel trace/span IDsEncodeOptions— egress configuration (exposure tier, frame cap)
Re-exports§
pub use any::render_chain;pub use category::Category;pub use error::DecodeError;pub use error::EncodeError;pub use exposure::Exposure;pub use failure::ServiceFailure;pub use frame::Frame;pub use remote::RemoteError;pub use trace::TraceContext;pub use traits::Aerro;pub use ext::ResultIntoStatusExt;pub use ext::StatusIntoResultExt;pub use traits::IntoStatus;pub use traits::TryFromStatus;pub use wire::decode::decode;pub use wire::encode::EncodeOptions;pub use wire::encode::encode;
Modules§
- any
- Error chain rendering utility.
- category
- Variant taxonomy — see spec §8.
- error
- Decode/encode error types — see spec §5.
- exposure
- Exposure tiers — see spec §9.
- ext
- Convenience extension traits for sites that want neither layer nor macro.
- failure
ServiceFailure<E>— typed error plus accumulated trace.- frame
- One hop in the call trace — see spec §7.
- remote
- Type-erased fallback for unknown wire types — see spec §5.
- trace
- OpenTelemetry trace and span IDs carried on every error envelope.
- traits
- wire
- Wire envelope (bincode) + encode/decode glue.
Constants§
- VERSION
- Current crate version.
Derive Macros§
- Aerro
- Derive the
aerro::Aerrotrait for an error enum.