pub struct ErrorChain { /* private fields */ }Expand description
A chain of ErrorContext records representing an error’s call stack.
Errors are pushed from innermost (root cause) to outermost (top-level
context). depth returns the number of frames.
§Examples
use oximedia_core::error_context::{ErrorContext, ErrorChain};
let root = ErrorContext::new("io", "read", "timeout");
let mut chain = ErrorChain::root(root);
chain.push(ErrorContext::new("demuxer", "read_packet", "I/O error"));
assert_eq!(chain.depth(), 2);Implementations§
Source§impl ErrorChain
impl ErrorChain
Sourcepub fn root(ctx: ErrorContext) -> Self
pub fn root(ctx: ErrorContext) -> Self
Creates a chain containing a single root (innermost) context.
Sourcepub fn push(&mut self, ctx: ErrorContext)
pub fn push(&mut self, ctx: ErrorContext)
Pushes an outer context onto the chain.
Sourcepub fn root_cause(&self) -> Option<&ErrorContext>
pub fn root_cause(&self) -> Option<&ErrorContext>
Returns the root (innermost / first-cause) context, or None if empty.
Sourcepub fn outermost(&self) -> Option<&ErrorContext>
pub fn outermost(&self) -> Option<&ErrorContext>
Returns the outermost context (most recently pushed), or None if empty.
Sourcepub fn iter(&self) -> impl Iterator<Item = &ErrorContext>
pub fn iter(&self) -> impl Iterator<Item = &ErrorContext>
Returns an iterator over all frames from root to outermost.
Trait Implementations§
Source§impl Clone for ErrorChain
impl Clone for ErrorChain
Source§fn clone(&self) -> ErrorChain
fn clone(&self) -> ErrorChain
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 Debug for ErrorChain
impl Debug for ErrorChain
Auto Trait Implementations§
impl Freeze for ErrorChain
impl RefUnwindSafe for ErrorChain
impl Send for ErrorChain
impl Sync for ErrorChain
impl Unpin for ErrorChain
impl UnsafeUnpin for ErrorChain
impl UnwindSafe for ErrorChain
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