pub struct StructError<T: DomainReason> { /* private fields */ }Implementations§
Source§impl<T: DomainReason> StructError<T>
impl<T: DomainReason> StructError<T>
Source§impl<T: DomainReason> StructError<T>
impl<T: DomainReason> StructError<T>
pub fn with_std_source<E>(self, source: E) -> Self
pub fn with_source<S>(self, source: S) -> Selfwhere
S: IntoSourcePayload,
pub fn with_struct_source<R>(self, source: StructError<R>) -> Selfwhere
R: DomainReason,
pub fn source_ref(&self) -> Option<&(dyn StdError + 'static)>
pub fn root_cause(&self) -> Option<&(dyn StdError + 'static)>
pub fn source_frames(&self) -> &[SourceFrame]
pub fn source_payload(&self) -> Option<SourcePayloadRef<'_>>
pub fn source_payload_kind(&self) -> Option<SourcePayloadKind>
pub fn root_cause_frame(&self) -> Option<&SourceFrame>
pub fn context_metadata(&self) -> ErrorMetadata
pub fn context_metadata_at(&self, index: usize) -> Option<&ErrorMetadata>
pub fn source_chain(&self) -> Vec<String>
pub fn into_std(self) -> OwnedStdStructError<T>
pub fn into_boxed_std(self) -> Box<dyn StdError + Send + Sync + 'static>
pub fn into_dyn_std(self) -> OwnedDynStdStructErrorwhere
T: DomainReason,
pub fn as_std(&self) -> StdStructRef<'_, T>
pub fn display_chain(&self) -> String
Source§impl<T: DomainReason> StructError<T>
impl<T: DomainReason> StructError<T>
pub fn builder(reason: T) -> StructErrorBuilder<T>
pub fn with_position(self, position: impl Into<String>) -> Self
pub fn with_context<C: Into<OperationContext>>(self, context: C) -> Self
pub fn contexts(&self) -> &[OperationContext]
pub fn with_detail(self, detail: impl Into<String>) -> Self
pub fn err<V>(self) -> Result<V, Self>
pub fn action_main(&self) -> Option<String>
pub fn locator_main(&self) -> Option<String>
pub fn path_segments(&self) -> Vec<String>
pub fn target_path(&self) -> Option<String>
Source§impl<T> StructError<T>where
T: DomainReason + ErrorIdentityProvider,
impl<T> StructError<T>where
T: DomainReason + ErrorIdentityProvider,
Sourcepub fn identity_snapshot(&self) -> ErrorIdentity
pub fn identity_snapshot(&self) -> ErrorIdentity
Build an ErrorIdentity from this error.
Source§impl<T: DomainReason> StructError<T>
impl<T: DomainReason> StructError<T>
Sourcepub fn report(&self) -> DiagnosticReport
pub fn report(&self) -> DiagnosticReport
Build a DiagnosticReport from this error.
The report carries human-readable reason, detail, context, and source frames — no identity or protocol data.
§Example
use orion_error::{StructError, UnifiedReason};
use orion_error::report::DiagnosticReport;
let err = StructError::from(UnifiedReason::validation_error())
.with_detail("field `email` is required");
let report: DiagnosticReport = err.report();
assert!(report.reason().contains("validation"));
assert_eq!(report.detail(), Some("field `email` is required"));Sourcepub fn into_report(self) -> DiagnosticReport
pub fn into_report(self) -> DiagnosticReport
Consume this error and return its human-readable diagnostic report.
§Example
use orion_error::{StructError, UnifiedReason};
let report = StructError::from(UnifiedReason::validation_error())
.with_detail("field `email` is required")
.into_report();
assert!(report.reason().contains("validation"));
assert_eq!(report.detail(), Some("field `email` is required"));Sourcepub fn report_redacted(&self, policy: &impl RedactPolicy) -> DiagnosticReport
pub fn report_redacted(&self, policy: &impl RedactPolicy) -> DiagnosticReport
Build a redacted DiagnosticReport using the provided policy.
§Example
use orion_error::{StructError, UnifiedReason};
use orion_error::report::RedactPolicy;
struct HideDetail;
impl RedactPolicy for HideDetail {
fn redact_value(&self, key: Option<&str>, value: &str) -> Option<String> {
if key == Some("detail") {
Some("<redacted>".to_string())
} else {
Some(value.to_string())
}
}
}
let report = StructError::from(UnifiedReason::validation_error())
.with_detail("token=abc")
.report_redacted(&HideDetail);
assert_eq!(report.detail(), Some("<redacted>"));Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Render this error as a human-readable diagnostic string.
Delegates to DiagnosticReport::render().
§Example
use orion_error::StructError;
use orion_error::reason::UnifiedReason;
let s = StructError::from(UnifiedReason::validation_error())
.with_detail("field `email` is required")
.render();
assert!(s.contains("validation"));
assert!(s.contains("field `email` is required"));Sourcepub fn render_redacted(&self, policy: &impl RedactPolicy) -> String
pub fn render_redacted(&self, policy: &impl RedactPolicy) -> String
Render a redacted human-readable diagnostic string.
§Example
use orion_error::{StructError, UnifiedReason};
use orion_error::report::RedactPolicy;
struct HideDetail;
impl RedactPolicy for HideDetail {
fn redact_value(&self, key: Option<&str>, value: &str) -> Option<String> {
if key == Some("detail") {
Some("<redacted>".to_string())
} else {
Some(value.to_string())
}
}
}
let rendered = StructError::from(UnifiedReason::validation_error())
.with_detail("token=abc")
.render_redacted(&HideDetail);
assert!(rendered.contains("detail: <redacted>"));Source§impl<T: DomainReason + ErrorIdentityProvider> StructError<T>
impl<T: DomainReason + ErrorIdentityProvider> StructError<T>
Sourcepub fn exposure(
&self,
exposure_policy: &impl ExposurePolicy,
) -> ErrorProtocolSnapshot
pub fn exposure( &self, exposure_policy: &impl ExposurePolicy, ) -> ErrorProtocolSnapshot
Build an ErrorProtocolSnapshot by combining identity, exposure
decision, and diagnostic report in one pass.
This is the primary entry point for protocol-level error output.
Requires ErrorIdentityProvider (provided by #[derive(OrionError)]).
§Example
use orion_error::protocol::DefaultExposurePolicy;
use orion_error::{StructError, UnifiedReason};
let err = StructError::from(UnifiedReason::system_error())
.with_detail("disk full");
let proto = err.exposure(&DefaultExposurePolicy);
assert_eq!(proto.identity.code, "sys.io_error");
assert_eq!(proto.decision.http_status, 500);Sourcepub fn into_exposure(
self,
exposure_policy: &impl ExposurePolicy,
) -> ErrorProtocolSnapshot
pub fn into_exposure( self, exposure_policy: &impl ExposurePolicy, ) -> ErrorProtocolSnapshot
Consume this error and return its protocol/exposure snapshot.
§Example
use orion_error::protocol::DefaultExposurePolicy;
use orion_error::{StructError, UnifiedReason};
let proto = StructError::from(UnifiedReason::system_error())
.with_detail("disk full")
.into_exposure(&DefaultExposurePolicy);
assert_eq!(proto.identity.code, "sys.io_error");
assert_eq!(proto.decision.http_status, 500);Trait Implementations§
Source§impl<T: Clone + DomainReason> Clone for StructError<T>
impl<T: Clone + DomainReason> Clone for StructError<T>
Source§fn clone(&self) -> StructError<T>
fn clone(&self) -> StructError<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more