pub struct TypedErr<E> { /* private fields */ }Expand description
A typed wrapper around a user error that provides Deref access to the inner error type.
This struct holds an Arc<anyhow::Error> internally and provides safe access to
the downcasted error reference. The Arc ensures the error remains valid for the
lifetime of this wrapper.
§Example
ⓘ
use query_flow::{QueryResultExt, TypedErr};
let result = db.query(MyQuery::new()).downcast_err::<MyError>()?;
match result {
Ok(value) => { /* success */ }
Err(typed_err) => {
// typed_err derefs to &MyError
println!("Error code: {}", typed_err.code);
}
}Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for TypedErr<E>
impl<E> RefUnwindSafe for TypedErr<E>where
E: RefUnwindSafe,
impl<E> Send for TypedErr<E>where
E: Send,
impl<E> Sync for TypedErr<E>where
E: Sync,
impl<E> Unpin for TypedErr<E>where
E: Unpin,
impl<E> UnwindSafe for TypedErr<E>where
E: UnwindSafe,
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