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/// Minimal API for beginners - start here
68pub mod simple;
69/// Core traits for error handling and composition
70pub mod traits;
71/// ComposableError and error context structures
72pub mod types;
73/// Validation type and associated traits for error accumulation
74pub mod validation;
75
76/// Advanced API level for library authors
77pub mod advanced;
78/// Intermediate API level for service developers
79pub mod intermediate;
80
81/// Async extensions for error handling (requires `async` feature)
82#[cfg(feature = "async")]
83pub mod async_ext;
84
85/// Async prelude - all async utilities in one import (requires `async` feature)
86#[cfg(feature = "async")]
87pub mod prelude_async;
88
89/// Tower integration - Layer and Service implementations (requires `tower` feature)
90#[cfg(feature = "tower")]
91pub mod tower;
92
93// Re-export common types that might be needed at root,
94// but encourage using prelude/intermediate/advanced modules.
95pub use context::*;
96pub use convert::*;
97pub use prelude::BoxedResult;
98pub use traits::*;
99pub use types::{
100 error_formatter::ErrorFormatConfig, BoxedComposableResult, ComposableError, ComposableResult,
101 ErrorContext, ErrorPipeline, ErrorVec, GroupContext, LazyContext, LazyGroupContext,
102};
103pub use validation::*;