error_rail/lib.rs
1//! Each submodule re-exports its public surface from here, so consumers can
2//! simply depend on `error_rail::*` or pick focused pieces as needed.
3//!
4//! # Examples
5//!
6//! ## Basic Error with Context
7//!
8//! ```
9//! use error_rail::{ComposableError, ErrorContext, group};
10//!
11//! let err = ComposableError::new("database connection failed")
12//! .with_context(group!(
13//! tag("db"),
14//! metadata("retry_count", "3")
15//! ))
16//! .set_code(500);
17//!
18//! assert!(err.to_string().contains("database connection failed"));
19//! assert_eq!(err.error_code(), Some(500));
20//! ```
21//!
22//! ## Validation Accumulation
23//!
24//! ```
25//! use error_rail::validation::Validation;
26//!
27//! let v1: Validation<&str, i32> = Validation::Valid(10);
28//! let v2: Validation<&str, i32> = Validation::invalid("error");
29//! let combined: Validation<&str, Vec<i32>> = vec![v1, v2].into_iter().collect();
30//!
31//! assert!(combined.is_invalid());
32//! ```
33//!
34//! ## Error Pipeline
35//!
36//! ```
37//! use error_rail::{ErrorPipeline, context};
38//!
39//! let result = ErrorPipeline::<i32, &str>::new(Err("failed"))
40//! .with_context(context!("operation: load_config"))
41//! .with_context(context!("user_id: 42"))
42//! .finish_boxed();
43//!
44//! if let Err(err) = result {
45//! let chain = err.error_chain();
46//! assert!(chain.contains("user_id: 42"));
47//! assert!(chain.contains("operation: load_config"));
48//! assert!(chain.contains("failed"));
49//! }
50//! ```
51#![cfg_attr(not(feature = "std"), no_std)]
52
53#[cfg(not(feature = "std"))]
54extern crate alloc;
55
56#[cfg(feature = "std")]
57extern crate std;
58
59/// Error context management and accumulation
60pub mod context;
61/// Error type conversions between Result, Validation, and ComposableError
62pub mod convert;
63/// Error handling macros for context creation
64pub mod macros;
65/// Convenience re-exports for quick starts
66pub mod prelude;
67/// Core traits for error handling and composition
68pub mod traits;
69/// ComposableError and error context structures
70pub mod types;
71/// Validation type and associated traits for error accumulation
72pub mod validation;
73
74/// Advanced API level for library authors
75pub mod advanced;
76/// Intermediate API level for service developers
77pub mod intermediate;
78
79// Re-export common types that might be needed at root,
80// but encourage using prelude/intermediate/advanced modules.
81pub use context::*;
82pub use convert::*;
83pub use traits::*;
84pub use types::{
85 error_formatter::ErrorFormatConfig, BoxedComposableResult, BoxedResult, ComposableError,
86 ComposableResult, ErrorContext, ErrorPipeline, ErrorVec, GroupContext, LazyContext,
87 LazyGroupContext,
88};
89pub use validation::*;