Skip to main content

Crate orion_error

Crate orion_error 

Source
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:

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§

DefaultExposurePolicy
OperationContext
StructError
Structured runtime error carrier with explicit bridge APIs for the standard error ecosystem.

Enums§

UvsReason
Universal error reason classification with clear hierarchical structure 统一错误原因分类 - 采用清晰的分层结构

Traits§

DomainReason
ErrorWith
ErrorWrapAs
IntoAs

Derive Macros§

ErrorCode
ErrorIdentityProvider
OrionError