Expand description
Exception Handling for Task Execution
This module provides comprehensive exception handling capabilities for task execution, including exception classification, custom handlers, traceback preservation, and cross-language exception serialization.
§Example
use celers_core::exception::{
TaskException, ExceptionCategory, ExceptionPolicy, ExceptionAction,
};
// Create an exception with traceback
let exception = TaskException::new("ValueError", "Invalid input: negative number")
.with_traceback(vec![
("process_data".to_string(), "tasks.py".to_string(), 42),
("validate_input".to_string(), "validators.py".to_string(), 15),
])
.with_category(ExceptionCategory::Retryable);
// Create a policy for handling exceptions
let policy = ExceptionPolicy::new()
.ignore_on(&["NotFoundError"])
.retry_on(&["TimeoutError", "ConnectionError"])
.fail_on(&["ValidationError"]);
// Determine action based on exception
let action = policy.get_action(&exception);Modules§
- exception_
types - Common exception types for categorization
Structs§
- Exception
Handler Chain - A chain of exception handlers
- Exception
Policy - Policy for handling exceptions
- Logging
Exception Handler - Built-in handler that logs exceptions
- Policy
Exception Handler - Built-in handler based on exception policy
- Task
Exception - A structured exception from task execution
- Traceback
Frame - A single frame in an exception traceback
Enums§
- Exception
Action - Action to take when an exception occurs
- Exception
Category - Category of an exception that determines retry behavior
Traits§
- Exception
Handler - Trait for custom exception handlers