Expand description
ComposableError and error context structures Error types and utilities.
This module provides a set of types and utilities for handling errors in a structured and composable way.
§Examples
use error_rail::{ComposableError, ErrorContext};
let err = ComposableError::new("database connection failed")
.with_context(ErrorContext::tag("db"))
.with_context(ErrorContext::location(file!(), line!()))
.set_code(500);
println!("{}", err.error_chain());
// Output: [db] -> main.rs:42 -> database connection failed (code: 500)§Choosing an error code type
ComposableError<E, C> defaults C to u32, but you can pin any
type that implements your domain rules. Use the provided aliases as
starting points or create project-specific ones:
use error_rail::{
ErrorContext,
SimpleComposableError,
TaggedComposableError,
ComposableError,
};
let http_error: SimpleComposableError<&str> = ComposableError::new("oops").set_code(500);
let tagged: TaggedComposableError<&str> =
ComposableError::new("missing feature").set_code("feature_disabled");Re-exports§
pub use composable_error::*;pub use error_context::*;pub use error_pipeline::*;pub use lazy_context::*;
Modules§
- composable_
error - Composable error type with structured context and error codes.
- error_
context - Rich, structured metadata for error contexts.
- error_
pipeline - lazy_
context - Deferred context generation for performance-critical paths.
Type Aliases§
- Boxed
Composable Error - Boxed
ComposableErrorfor reduced stack size. - Boxed
Composable Result - Result alias with boxed
ComposableErrorfor reduced stack size. - Composable
Result - Result alias that wraps failures in
ComposableError. - Error
Vec - SmallVec-backed collection used for accumulating contexts/errors.
- Simple
Composable Error - Convenience alias for
ComposableErrorwith the default numeric code type. - Tagged
Composable Error - Convenience alias for
ComposableErrorwith static string codes.