pub struct TaskError { /* private fields */ }Expand description
Represents an error that occurred during task execution.
TaskError wraps an underlying error and preserves both the error itself and its
concrete type information. This allows for type-safe error handling and downcasting
while maintaining thread safety through Arc wrapping.
The error type stores:
- The actual error as a trait object (
dyn Error + Send + Sync) - The original error’s type name as a string for debugging and logging
- An optional source reference to the original concrete error for downcasting
§Thread Safety
TaskError is designed to be safely shared across threads, with all internal
references wrapped in Arc and requiring Send + Sync bounds.
§Example
use genja_core::task::TaskError;
use std::io;
// Create a TaskError from a standard error
let io_error = io::Error::new(io::ErrorKind::NotFound, "file not found");
let task_error = TaskError::new(io_error);
// Access error information
println!("Error: {}", task_error.error());
println!("Error type: {}", task_error.error_type());
// Attempt to downcast to the original error type
if let Some(io_err) = task_error.downcast_ref::<io::Error>() {
println!("Original IO error kind: {:?}", io_err.kind());
}Implementations§
Source§impl TaskError
impl TaskError
Trait Implementations§
Source§impl Error for TaskError
impl Error for TaskError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + '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()
Auto Trait Implementations§
impl !RefUnwindSafe for TaskError
impl !UnwindSafe for TaskError
impl Freeze for TaskError
impl Send for TaskError
impl Sync for TaskError
impl Unpin for TaskError
impl UnsafeUnpin for TaskError
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