pub struct StructError<T: DomainReason> { /* private fields */ }Expand description
Structured error type containing detailed error information including error source, contextual data, and debugging information.
Implementations§
Source§impl<T: DomainReason> StructError<T>
impl<T: DomainReason> StructError<T>
Source§impl<T: DomainReason> StructError<T>
impl<T: DomainReason> StructError<T>
Source§impl<T: DomainReason> StructError<T>
impl<T: DomainReason> StructError<T>
Sourcepub fn with_source<E>(self, source: E) -> Self
pub fn with_source<E>(self, source: E) -> Self
Attach a non-structured source error.
For StructError<_> sources, use with_struct_source(...) so metadata and
structured source frames are preserved.
pub fn with_struct_source<R>(self, source: StructError<R>) -> Self
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 root_cause_frame(&self) -> Option<&SourceFrame>
pub fn context_metadata(&self) -> ErrorMetadata
pub fn source_chain(&self) -> Vec<String>
pub fn display_chain(&self) -> String
pub fn render(&self, mode: RenderMode) -> String
pub fn render_redacted( &self, mode: RenderMode, policy: &impl RedactPolicy, ) -> String
Source§impl<T: DomainReason> StructError<T>
impl<T: DomainReason> StructError<T>
pub fn builder(reason: T) -> StructErrorBuilder<T>
Sourcepub fn with_position(self, position: impl Into<String>) -> Self
pub fn with_position(self, position: impl Into<String>) -> Self
使用示例 self.with_position(location!());
pub fn with_context(self, context: CallContext) -> 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 target_main(&self) -> Option<String>
Sourcepub fn target(&self) -> Option<String>
pub fn target(&self) -> Option<String>
Compatibility alias for target_main().
Prefer target_main() in new code when pairing it with target_path().
pub fn path_segments(&self) -> Vec<String>
pub fn target_path(&self) -> Option<String>
Source§impl<T: DomainReason> StructError<T>
impl<T: DomainReason> StructError<T>
pub fn report(&self) -> ErrorReport
pub fn report_redacted(&self, policy: &impl RedactPolicy) -> ErrorReport
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>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<R1, R2> ConvStructError<R2> for StructError<R1>
impl<R1, R2> ConvStructError<R2> for StructError<R1>
fn conv(self) -> StructError<R2>
Source§impl<T: Debug + DomainReason> Debug for StructError<T>
impl<T: Debug + DomainReason> Debug for StructError<T>
Source§impl<T: DomainReason> Deref for StructError<T>
impl<T: DomainReason> Deref for StructError<T>
Source§impl<T: Display + DomainReason + ErrorCode> Display for StructError<T>
impl<T: Display + DomainReason + ErrorCode> Display for StructError<T>
Source§impl<T> Error for StructError<T>
impl<T> Error for StructError<T>
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl<T: DomainReason + ErrorCode> ErrorCode for StructError<T>
impl<T: DomainReason + ErrorCode> ErrorCode for StructError<T>
fn error_code(&self) -> i32
Source§impl<T: DomainReason> ErrorWith for StructError<T>
impl<T: DomainReason> ErrorWith for StructError<T>
Source§impl<T> From<T> for StructError<T>where
T: DomainReason,
impl<T> From<T> for StructError<T>where
T: DomainReason,
Source§impl<T: DomainReason> PartialEq for StructError<T>
impl<T: DomainReason> PartialEq for StructError<T>
Source§impl<T: DomainReason> StructErrorTrait<T> for StructError<T>
impl<T: DomainReason> StructErrorTrait<T> for StructError<T>
fn get_reason(&self) -> &T
fn get_detail(&self) -> Option<&String>
fn get_target(&self) -> Option<String>
Source§impl<R1, R2> WrapStructError<R2> for StructError<R1>
impl<R1, R2> WrapStructError<R2> for StructError<R1>
fn wrap(self, reason: R2) -> 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more