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)) -> Self
pub fn from_panic_payload(payload: &(dyn Any + Send)) -> Self
Sourcepub const fn panicked_without_message() -> Self
pub const fn panicked_without_message() -> Self
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> Clone for BatchTaskError<E>
impl<E: Clone> Clone for BatchTaskError<E>
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> Debug for BatchTaskError<E>
impl<E: Debug> Debug for BatchTaskError<E>
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> PartialEq for BatchTaskError<E>
impl<E: PartialEq> PartialEq for BatchTaskError<E>
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 ==.