pub enum BatchTaskError<E> {
Failed(E),
Panicked {
message: Option<String>,
},
}Expand description
Error recorded for one task inside a batch execution.
Use this type to distinguish a task’s returned business error from a panic captured while running that task.
use qubit_batch::BatchTaskError;
let failed = BatchTaskError::Failed("invalid record");
assert!(failed.is_failed());
assert_eq!(failed.panic_message(), None);
let panicked: BatchTaskError<&'static str> = BatchTaskError::panicked("boom");
assert!(panicked.is_panicked());
assert_eq!(panicked.panic_message(), Some("boom"));§Type Parameters
E- The task-specific error type.
Variants§
Implementations§
Source§impl<E> BatchTaskError<E>
impl<E> BatchTaskError<E>
Sourcepub fn from_panic_payload(
payload: &(dyn Any + Send + 'static),
) -> BatchTaskError<E>
pub fn from_panic_payload( payload: &(dyn Any + Send + 'static), ) -> BatchTaskError<E>
Sourcepub fn panicked(message: impl Into<String>) -> BatchTaskError<E>
pub fn panicked(message: impl Into<String>) -> BatchTaskError<E>
Sourcepub const fn panicked_without_message() -> BatchTaskError<E>
pub const fn panicked_without_message() -> BatchTaskError<E>
Creates a panicked task error without a readable message.
§Returns
A panicked task error with no captured message.
Sourcepub const fn is_failed(&self) -> bool
pub const fn is_failed(&self) -> bool
Returns whether this task error wraps the task’s own error value.
§Returns
true if this error is Self::Failed.
Sourcepub const fn is_panicked(&self) -> bool
pub const fn is_panicked(&self) -> bool
Sourcepub fn panic_message(&self) -> Option<&str>
pub fn panic_message(&self) -> Option<&str>
Returns the captured panic message, if one is available.
§Returns
Some(message) when the panic payload was a string, or None for
business errors and non-string panic payloads.
Trait Implementations§
Source§impl<E> Clone for BatchTaskError<E>where
E: Clone,
impl<E> Clone for BatchTaskError<E>where
E: Clone,
Source§fn clone(&self) -> BatchTaskError<E>
fn clone(&self) -> BatchTaskError<E>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<E> Debug for BatchTaskError<E>where
E: Debug,
impl<E> Debug for BatchTaskError<E>where
E: Debug,
Source§impl<E> Display for BatchTaskError<E>where
E: Display,
impl<E> Display for BatchTaskError<E>where
E: Display,
Source§impl<E> Error for BatchTaskError<E>where
E: Error + 'static,
impl<E> Error for BatchTaskError<E>where
E: Error + 'static,
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the wrapped task error as the source when this error represents a business failure.
§Returns
Some(error) for Self::Failed, or None for task panics because a
panic payload is not an error source.
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl<E> PartialEq for BatchTaskError<E>where
E: PartialEq,
impl<E> PartialEq for BatchTaskError<E>where
E: PartialEq,
Source§fn eq(&self, other: &BatchTaskError<E>) -> bool
fn eq(&self, other: &BatchTaskError<E>) -> bool
self and other values to be equal, and is used by ==.impl<E> Eq for BatchTaskError<E>where
E: Eq,
impl<E> StructuralPartialEq for BatchTaskError<E>
Auto Trait Implementations§
impl<E> Freeze for BatchTaskError<E>where
E: Freeze,
impl<E> RefUnwindSafe for BatchTaskError<E>where
E: RefUnwindSafe,
impl<E> Send for BatchTaskError<E>where
E: Send,
impl<E> Sync for BatchTaskError<E>where
E: Sync,
impl<E> Unpin for BatchTaskError<E>where
E: Unpin,
impl<E> UnsafeUnpin for BatchTaskError<E>where
E: UnsafeUnpin,
impl<E> UnwindSafe for BatchTaskError<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more