1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//! # Error Forge
//!
//! Error Forge is a pragmatic Rust error-handling crate for applications that need
//! structured metadata, readable output, and operational hooks without forcing a
//! single application architecture.
//!
//! It provides:
//!
//! - [`ForgeError`] for stable error metadata
//! - [`AppError`] for immediate use in small and medium projects
//! - [`define_errors!`] for declarative custom enums
//! - [`group!`] for coarse-grained composition
//! - optional derive support with `#[derive(ModError)]`
//! - context wrapping, error codes, collectors, logging hooks, and console formatting
//! - synchronous retry and circuit-breaker helpers in [`recovery`]
//!
//! ## Quick Start
//!
//! ```
//! use error_forge::{define_errors, ForgeError};
//!
//! define_errors! {
//! pub enum ServiceError {
//! #[error(display = "Configuration error: {message}", message)]
//! #[kind(Config, status = 500)]
//! Config { message: String },
//!
//! #[error(display = "Request to {endpoint} failed", endpoint)]
//! #[kind(Network, retryable = true, status = 503)]
//! Network { endpoint: String },
//! }
//! }
//!
//! let error = ServiceError::config("Missing DATABASE_URL".to_string());
//! assert_eq!(error.kind(), "Config");
//! ```
//!
//! ## Built-in Formatting
//!
//! ```
//! use error_forge::{console_theme::print_error, AppError};
//!
//! let error = AppError::config("Database connection failed");
//! print_error(&error);
//! ```
// Re-export core types and traits
pub use crate;
pub use crate;
// Historical re-export. `Result` shadows `std::result::Result` in
// glob imports; deprecated in favour of `AppResult`. Kept for
// source compatibility through the `1.x` line.
pub use crateResult;
// Re-export context module
pub use crate;
// Re-export registry module
pub use crate;
// Re-export collector module
pub use crate;
// Re-export logging module
pub use crate;
// Re-export async module (when enabled)
pub use crate;
// Re-export hook types from `macros` — explicitly named so the
// public surface stays under our control. `define_errors!` and
// `group!` are re-exported automatically because they are
// `#[macro_export]`'d.
pub use crate;
// Optional re-export of the proc macro
pub use *;
/// Internal re-exports for use by macros expanded in user crates.
///
/// This module is not part of the public API. Items here may
/// change at any time without notice. They are exposed only so
/// that `define_errors!` (and other macros that expand into user
/// code) can reference dependencies through `$crate::__private::*`
/// without forcing every user to add those crates to their own
/// `Cargo.toml`.
// Extension methods are implemented in error.rs