error-rail
Composable, metadata-friendly error utilities for Rust.
error-rail provides a middle ground between simple string errors and full-blown tracing systems. It allows you to attach rich, structured context to errors and collect multiple validation failures without early returns.
Quick Start
New to error-rail? Check out the Quick Start Guide for a beginner-friendly introduction.
Key Features
1. Structured Context
Wrap any error in ComposableError and attach layered metadata like messages, file locations, and tags.
use ;
let err = new
.with_context
.with_context
.with_context;
2. Validation Accumulation
Collect multiple errors instead of failing fast. Ideal for form validation or batch processing.
use Validation;
let v1 = valid;
let v2 = invalid;
let combined: = vec!.into_iter.collect;
assert!;
3. Ergonomic Traits
IntoErrorContext: Convert your own types into error context.WithError: Transform error types while preserving success values.ErrorOps: Unified operations for recovery and mapping.
Module Overview
context: Core context types and pipeline builders.convert: Helpers to switch betweenResult,Validation, andComposableError.macros:context!,location!,tag!,metadata!,railfor easy context creation.traits: Foundational traits (ErrorCategory,ErrorOps, etc.).types:ComposableErrorand related type aliases.validation: TheValidationenum and accumulators.
Installation
Examples
Run the bundled examples to see error-rail in action:
License
Apache-2.0