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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
//! # orion-error — structured error governance for large Rust codebases
//!
//! ## Decision flow
//!
//! When you have an error, the question is: **what do you need to do with it?**
//!
//! ```text
//! ┌─ I have an error ──────────────────────────────────────────┐
//! │ │
//! │ Need to print it for a human? │
//! │ → err.report().render() │
//! │ │
//! │ Need to return it to an HTTP/RPC/CLI boundary? │
//! │ → err.exposure(&policy).to_http_error_json() │
//! │ → err.exposure(&policy).to_rpc_error_json() │
//! │ → err.exposure(&policy).to_cli_error_json() │
//! │ │
//! │ Need to bridge to std::error::Error? │
//! │ → err.as_std() / err.into_std() / err.into_dyn_std() │
//! │ │
//! │ Just need to log and move on? │
//! │ → err.display_chain() │
//! │ → cli::print_error(&err) │
//! └─────────────────────────────────────────────────────────────┘
//! ```
//!
//! The key boundary:
//!
//! - [`StructError::report()`] gives you a [`DiagnosticReport`] — human diagnostics,
//! redaction, text rendering. Only requires [`reason::DomainReason`].
//! - [`StructError::exposure()`] gives you an [`ErrorProtocolSnapshot`] —
//! identity + exposure decision + report, the unified protocol input.
//! Requires [`reason::DomainReason`] + [`reason::ErrorIdentityProvider`].
//!
//! If you only have [`reason::DomainReason`], you can always `report()`. If you
//! also implement [`reason::ErrorIdentityProvider`] (via `#[derive(OrionError)]`),
//! you can use `exposure()` and the full protocol projection stack.
//!
//! Module split:
//!
//! - [`report`] is the human-facing diagnostics layer
//! - [`protocol`] is the protocol/exposure projection layer
//!
//! Root-surface guardrails:
//!
//! - derive macros stay importable from the crate root
//! - runtime identity traits live under [`reason`]
//! - removed root trait/type re-exports and old extension modules must not drift back
//!
//! ```compile_fail
//! use orion_error::DomainReason;
//! ```
//!
//! ```compile_fail
//! use orion_error::ErrorCode;
//!
//! trait NeedsRootTrait: ErrorCode {}
//! ```
//!
//! ```compile_fail
//! use orion_error::ErrorIdentityProvider;
//!
//! fn accepts_root_trait<T: ErrorIdentityProvider>(_value: &T) {}
//! ```
//!
//! ```compile_fail
//! use orion_error::bridge::*;
//! ```
//!
//! ```compile_fail
//! use orion_error::testing::*;
//! ```
//!
//! ```compile_fail
//! use orion_error::test_prelude::*;
//! ```
//!
//! ```compile_fail
//! use orion_error::ErrorWith;
//! ```
//!
//! ```compile_fail
//! use orion_error::ErrorWrapAs;
//! ```
//!
//! ```compile_fail
//! use orion_error::IntoAs;
//! ```
//!
//! ```compile_fail
//! use orion_error::{StructError, UnifiedReason};
//!
//! let _ = StructError::from(UnifiedReason::system_error())
//! .attach_source(std::io::Error::other("disk offline"));
//! ```
//!
//! ```compile_fail
//! use orion_error::types::ErrorIdentity;
//! ```
//!
//! ```compile_fail
//! use orion_error::DefaultExposurePolicy;
//! ```
//!
//! ```compile_fail
//! use orion_error::traits_ext::*;
//! ```
//!
//! ```compile_fail
//! use orion_error::{StructError, UnifiedReason};
//!
//! let report = StructError::from(UnifiedReason::system_error()).report();
//! let _ = report.projection;
//! ```
//!
//! ```compile_fail
//! use orion_error::report::print_error;
//! ```
//!
//! ```compile_fail
//! use orion_error::{StructError, UnifiedReason};
//!
//! let report = StructError::from(UnifiedReason::system_error()).report();
//! let _ = report.path();
//! ```
//!
//! ```compile_fail
//! use orion_error::{StructError, UnifiedReason};
//!
//! let report = StructError::from(UnifiedReason::system_error()).report();
//! let _ = report.root_metadata();
//! ```
//!
//! ```compile_fail
//! use orion_error::{StructError, UnifiedReason};
//!
//! let report = StructError::from(UnifiedReason::system_error()).report();
//! let _ = report.source_frames();
//! ```
//!
//! ```compile_fail
//! use orion_error::{OperationContext, StructError, UnifiedReason};
//!
//! let _ = OperationContext::doing("load config").target();
//! let _ = StructError::from(UnifiedReason::system_error()).target_main();
//! ```
//!
//! ```rust
//! use orion_error::protocol::DefaultExposurePolicy;
//! use orion_error::{StructError, UnifiedReason};
//!
//! let proto = StructError::from(UnifiedReason::system_error())
//! .exposure(&DefaultExposurePolicy);
//! let _ = proto.report();
//! ```
//!
//! ```rust,ignore
//! // This example requires the `derive` feature (enabled by default).
//! use orion_error::OrionError;
//! use orion_error::reason::{ErrorCategory, ErrorCode, ErrorIdentityProvider};
//!
//! #[derive(Debug, Clone, PartialEq, OrionError)]
//! enum DemoReason {
//! #[orion_error(identity = "logic.demo_reason")]
//! Demo,
//! }
//!
//! let reason = DemoReason::Demo;
//! assert_eq!(reason.error_code(), 500);
//! assert_eq!(reason.stable_code(), "logic.demo_reason");
//! assert_eq!(reason.error_category(), ErrorCategory::Logic);
//! ```
extern crate self as orion_error;
pub use ;
pub use ;
/// Primary-path traits and types for convenient wildcard imports.
///
/// # Example
/// ```rust,ignore
/// use orion_error::prelude::*;
/// ```
/// Runtime-layer types.
///
/// These are the primary carriers used while an error is still moving through
/// application code.
/// Report-layer types for rendering and redaction.
/// CLI-side output helpers.
/// Standard-error ecosystem interop: bridge types for entering the standard
/// `std::error::Error` ecosystem.
///
/// Provides owned and borrowed wrappers that implement `StdError` and delegate
/// to the underlying [`StructError`]. Use these when you need to pass an
/// orion-error through an interface that expects `dyn Error`.
/// Protocol/exposure-layer types for boundary projections.
/// Reason-layer enums and traits.
/// Conversion traits for the current primary paths.
/// Development and validation-only helpers.