Expand description
§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?
┌─ 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_snapshot(&policy).to_http_error_json() │
│ → err.exposure_snapshot(&policy).to_rpc_error_json() │
│ → err.exposure_snapshot(&policy).to_cli_error_json() │
│ │
│ Need a stable machine-readable snapshot? │
│ → err.snapshot().stable_export() │
│ │
│ 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() │
│ → report::print_error(&err) │
└─────────────────────────────────────────────────────────────┘The key boundary:
StructError::report()gives you a [DiagnosticReport] — human diagnostics, redaction, text rendering. Only requiresDomainReason.StructError::exposure_snapshot()gives you an [ErrorProtocolSnapshot] — identity + exposure decision + report, the unified protocol input. RequiresDomainReason+ErrorIdentityProvider.
If you only have DomainReason, you can always report(). If you
also implement ErrorIdentityProvider (via #[derive(OrionError)]),
you can use exposure_snapshot() and the full protocol projection stack.
Modules§
- advanced_
prelude - Wildcard imports for protocol/schema checks and migration-oriented tests.
- bridge
- Explicit bridge types for entering the standard error ecosystem.
- compat_
prelude - Compatibility wildcard imports for legacy conversion APIs.
- compat_
traits - Compatibility trait exports for legacy conversion helpers.
- conversion
- Conversion traits for the current primary paths.
- conversion_
ext - Advanced conversion helpers that are not part of the default import path.
- prelude
- Primary-path traits and types for convenient wildcard imports.
- reason
- Reason-layer enums and traits.
- report
- Report-layer types for rendering and redaction.
- runtime
- Runtime-layer types.
- snapshot
- Snapshot-layer types and stable snapshot schema exports.
- testcase
- traits_
ext - Grouped conversion and context extension traits.
- types
- Shared data carriers and enums that are still convenient outside the layered namespaces.
Macros§
- location
- op_
context - 在调用处展开
module_path!(),便于自动日志输出正确的模块路径。
Structs§
- Default
Exposure Policy - Operation
Context - Struct
Error - Structured runtime error carrier with explicit bridge APIs for the standard error ecosystem.
Enums§
- UvsReason
- Universal error reason classification with clear hierarchical structure 统一错误原因分类 - 采用清晰的分层结构