pub trait ExposurePolicy {
// Provided methods
fn http_status(&self, _identity: &ErrorIdentity) -> u16 { ... }
fn visibility(&self, _identity: &ErrorIdentity) -> Visibility { ... }
fn default_hints(
&self,
_identity: &ErrorIdentity,
) -> &'static [&'static str] { ... }
fn retryable(&self, _identity: &ErrorIdentity) -> bool { ... }
fn decide(&self, identity: &ErrorIdentity) -> ExposureDecision { ... }
}Expand description
Policy that maps an error identity to protocol-level exposure decisions.
Implement this to control HTTP status codes, visibility, hints, and retryability per error identity.
§Example
use orion_error::protocol::{ExposurePolicy, Visibility};
use orion_error::ErrorIdentity;
struct MyPolicy;
impl ExposurePolicy for MyPolicy {
fn http_status(&self, identity: &ErrorIdentity) -> u16 {
match identity.code.as_str() {
"biz.not_found" => 404,
_ => 500,
}
}
}All methods have defaults — override only what you need.
§Common override patterns
| Method | Override frequency | Typical use |
|---|---|---|
http_status | Most common | Map error identity to HTTP status code |
visibility | Common | Control which errors expose detail publicly |
retryable | Occasional | Mark transient errors as retryable |
default_hints | Rare | Provide user-facing recovery hints |
decide | Rare | Override the entire composition logic |
Most implementations only override http_status
and optionally visibility. The rest can be left
at their defaults.