Skip to main content

StructError

Struct StructError 

Source
pub struct StructError<T: DomainReason> { /* private fields */ }
Expand description

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

use orion_error::{StructError, UvsReason};

let err = StructError::from(UvsReason::system_error());
let _ = std::error::Error::source(&err);
use orion_error::{StructError, UvsReason};

let err = StructError::from(UvsReason::system_error());
let bridged = err.as_std();
let _ = std::error::Error::source(&bridged);

Implementations§

Source§

impl<T: DomainReason> StructError<T>

Source

pub fn imp(&self) -> &StructErrorImpl<T>

Source§

impl<T: DomainReason> StructError<T>

Source

pub fn new( reason: T, detail: Option<String>, position: Option<String>, context: Vec<OperationContext>, ) -> Self

Source§

impl<T: DomainReason> StructError<T>

Source

pub fn attach_source<S>(self, source: S) -> Self

Attach any source that can be converted into the dual-channel source payload model.

Ordinary StdError values attach as SourcePayloadKind::Std, while StructError<_> attaches as SourcePayloadKind::Struct.

Source

pub fn with_std_source<E>(self, source: E) -> Self
where E: StdError + Send + Sync + 'static,

Attach a non-structured source error.

For StructError<_> sources, use with_struct_source(...) so metadata and structured source frames are preserved.

Source

pub fn with_source<S>(self, source: S) -> Self

Recommended helper that auto-routes either a standard source error or an existing StructError<_> through the dual-channel source model.

Use with_std_source(...) / with_struct_source(...) instead when the call site should make the source kind explicit.

Source

pub fn with_struct_source<R>(self, source: StructError<R>) -> Self
where R: DomainReason + ErrorCode + Debug + Display + Send + Sync + 'static,

Source

pub fn source_ref(&self) -> Option<&(dyn StdError + 'static)>

Source

pub fn root_cause(&self) -> Option<&(dyn StdError + 'static)>

Source

pub fn source_frames(&self) -> &[SourceFrame]

Source

pub fn source_payload(&self) -> Option<SourcePayloadRef<'_>>

Source

pub fn source_payload_kind(&self) -> Option<SourcePayloadKind>

Source

pub fn root_cause_frame(&self) -> Option<&SourceFrame>

Source

pub fn context_metadata(&self) -> ErrorMetadata

Source

pub fn source_chain(&self) -> Vec<String>

Source

pub fn into_std(self) -> OwnedStdStructError<T>
where T: ErrorCode + Debug + Display + Send + Sync + 'static,

Source

pub fn into_boxed_std(self) -> Box<dyn StdError + Send + Sync + 'static>
where T: ErrorCode + Debug + Display + Send + Sync + 'static,

Source

pub fn into_dyn_std(self) -> OwnedDynStdStructError
where T: ErrorCode + Debug + Display + Send + Sync + 'static,

Source

pub fn as_std(&self) -> StdStructRef<'_, T>
where T: ErrorCode + Debug + Display + Send + Sync + 'static,

Source

pub fn display_chain(&self) -> String
where T: ErrorCode + Debug + Display + 'static,

Source

pub fn render(&self, mode: RenderMode) -> String

Source

pub fn render_redacted( &self, mode: RenderMode, policy: &impl RedactPolicy, ) -> String

Source§

impl<T: DomainReason> StructError<T>

Source

pub fn builder(reason: T) -> StructErrorBuilder<T>

Source

pub fn with_position(self, position: impl Into<String>) -> Self

使用示例 self.with_position(location!());

Source

pub fn with_context<C: Into<OperationContext>>(self, context: C) -> Self

Source

pub fn contexts(&self) -> &[OperationContext]

Source

pub fn with_detail(self, detail: impl Into<String>) -> Self

Source

pub fn err<V>(self) -> Result<V, Self>

Source

pub fn target_main(&self) -> Option<String>

Source

pub fn action_main(&self) -> Option<String>

Source

pub fn locator_main(&self) -> Option<String>

Source

pub fn target(&self) -> Option<String>

Compatibility alias for target_main().

Prefer target_main() in new code when pairing it with target_path().

Source

pub fn path_segments(&self) -> Vec<String>

Source

pub fn target_path(&self) -> Option<String>

Source§

impl<T: DomainReason> StructError<T>

Source§

impl<T> StructError<T>
where T: DomainReason + ErrorIdentityProvider,

Source

pub fn exposure_view(&self) -> ExposureView

Source

pub fn into_exposure_view(self) -> ExposureView

Source

pub fn exposure_snapshot( &self, exposure_policy: &impl ExposurePolicy, ) -> ErrorProtocolSnapshot

Source

pub fn into_exposure_snapshot( self, exposure_policy: &impl ExposurePolicy, ) -> ErrorProtocolSnapshot

Source

pub fn http_response( &self, exposure_policy: &impl ExposurePolicy, ) -> ErrorHttpResponse

Source

pub fn cli_response( &self, exposure_policy: &impl ExposurePolicy, ) -> ErrorCliResponse

Source

pub fn log_response( &self, exposure_policy: &impl ExposurePolicy, ) -> ErrorLogResponse

Source

pub fn rpc_response( &self, exposure_policy: &impl ExposurePolicy, ) -> ErrorRpcResponse

Source

pub fn render_user_debug(&self, exposure_policy: &impl ExposurePolicy) -> String

Source

pub fn render_user_debug_redacted( &self, exposure_policy: &impl ExposurePolicy, redact_policy: &impl RedactPolicy, ) -> String

Source

pub fn render_debug_summary( &self, exposure_policy: &impl ExposurePolicy, ) -> String

Source§

impl<T: DomainReason> StructError<T>

Source§

impl<T> StructError<T>
where T: DomainReason + ErrorIdentityProvider,

Trait Implementations§

Source§

impl<T: Clone + DomainReason> Clone for StructError<T>

Source§

fn clone(&self) -> StructError<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<R1, R2> ConvStructError<R2> for StructError<R1>
where R1: DomainReason, R2: DomainReason + From<R1>,

Source§

fn conv(self) -> StructError<R2>

Source§

impl<T: Debug + DomainReason> Debug for StructError<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: DomainReason> Deref for StructError<T>

Source§

type Target = StructErrorImpl<T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: Display + DomainReason + ErrorCode> Display for StructError<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: DomainReason + ErrorCode> ErrorCode for StructError<T>

Source§

fn error_code(&self) -> i32

Source§

impl<T> ErrorIdentityProvider for StructError<T>
where T: DomainReason + ErrorIdentityProvider,

Source§

impl<T: DomainReason> ErrorWith for StructError<T>

Source§

fn want<S: Into<String>>(self, desc: S) -> Self

👎Deprecated since 0.7.0:

use doing(…) for action contexts; use at(…) for locator/resource contexts

Source§

fn position<S: Into<String>>(self, pos: S) -> Self

Source§

fn with_context<C: Into<OperationContext>>(self, ctx: C) -> Self

Source§

fn attach_context<C: Into<OperationContext>>(self, ctx: C) -> Self
where Self: Sized,

👎Deprecated since 0.7.0:

use with_context(…) for full context frames; use doing(…) / at(…) for semantic context helpers

Source§

fn with<C: Into<OperationContext>>(self, ctx: C) -> Self
where Self: Sized,

👎Deprecated since 0.7.0:

use with_context(…) for full context frames; use at(…) / doing(…) for semantic context helpers

Source§

fn doing<S: Into<String>>(self, desc: S) -> Self
where Self: Sized,

Source§

fn at<C: Into<OperationContext>>(self, ctx: C) -> Self
where Self: Sized,

Source§

impl<'a, R> From<&'a StructError<R>> for StdStructRef<'a, R>
where R: DomainReason,

Source§

fn from(value: &'a StructError<R>) -> Self

Converts to this type from the input type.
Source§

impl<T: DomainReason> From<&StructError<T>> for DiagnosticReport

Source§

fn from(value: &StructError<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: DomainReason> From<&StructError<T>> for ErrorSnapshot

Source§

fn from(value: &StructError<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: DomainReason> From<&StructError<T>> for StableErrorSnapshot

Source§

fn from(value: &StructError<T>) -> Self

Converts to this type from the input type.
Source§

impl<R> From<StructError<R>> for OwnedDynStdStructError
where R: DomainReason + ErrorCode + Debug + Display + Send + Sync + 'static,

Source§

fn from(value: StructError<R>) -> Self

Converts to this type from the input type.
Source§

impl<R> From<StructError<R>> for OwnedStdStructError<R>
where R: DomainReason,

Source§

fn from(value: StructError<R>) -> Self

Converts to this type from the input type.
Source§

impl<T: DomainReason> From<StructError<T>> for DiagnosticReport

Source§

fn from(value: StructError<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: DomainReason> From<StructError<T>> for ErrorSnapshot

Source§

fn from(value: StructError<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: DomainReason> From<StructError<T>> for StableErrorSnapshot

Source§

fn from(value: StructError<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<T> for StructError<T>
where T: DomainReason,

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl<R> IntoSourcePayload for StructError<R>
where R: DomainReason + ErrorCode + Debug + Display + Send + Sync + 'static,

Source§

impl<T: DomainReason> PartialEq for StructError<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<R1, R2> WrapStructError<R2> for StructError<R1>
where R1: DomainReason + ErrorCode + Display + Debug + Send + Sync + 'static, R2: DomainReason,

Source§

fn wrap(self, reason: R2) -> StructError<R2>

Source§

impl<R1, R2> WrapStructErrorAs<R2> for StructError<R1>
where R1: DomainReason + ErrorCode + Display + Debug + Send + Sync + 'static, R2: DomainReason,

Source§

fn wrap_as(self, reason: R2, detail: impl Into<String>) -> StructError<R2>

Auto Trait Implementations§

§

impl<T> Freeze for StructError<T>

§

impl<T> !RefUnwindSafe for StructError<T>

§

impl<T> Send for StructError<T>
where T: Send,

§

impl<T> Sync for StructError<T>
where T: Sync,

§

impl<T> Unpin for StructError<T>

§

impl<T> UnsafeUnpin for StructError<T>

§

impl<T> !UnwindSafe for StructError<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UvsFrom for T
where T: From<UvsReason>,

Source§

fn from_conf() -> Self

Source§

fn from_conf_reason(reason: ConfErrReason) -> Self

Source§

fn from_data() -> Self

Source§

fn from_sys() -> Self

Source§

fn from_biz() -> Self

Source§

fn from_logic() -> Self

Source§

fn from_rule() -> Self

Source§

fn from_res() -> Self

Source§

fn from_net() -> Self

Source§

fn from_timeout() -> Self

Source§

fn from_validation() -> Self

Source§

fn from_not_found() -> Self

Source§

fn from_permission() -> Self

Source§

fn from_external() -> Self