Module types

Module types 

Source
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§

BoxedComposableError
Boxed ComposableError for reduced stack size.
BoxedComposableResult
Result alias with boxed ComposableError for reduced stack size.
ComposableResult
Result alias that wraps failures in ComposableError.
ErrorVec
SmallVec-backed collection used for accumulating contexts/errors.
SimpleComposableError
Convenience alias for ComposableError with the default numeric code type.
TaggedComposableError
Convenience alias for ComposableError with static string codes.