Module exception

Module exception 

Source
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§

ExceptionHandlerChain
A chain of exception handlers
ExceptionPolicy
Policy for handling exceptions
LoggingExceptionHandler
Built-in handler that logs exceptions
PolicyExceptionHandler
Built-in handler based on exception policy
TaskException
A structured exception from task execution
TracebackFrame
A single frame in an exception traceback

Enums§

ExceptionAction
Action to take when an exception occurs
ExceptionCategory
Category of an exception that determines retry behavior

Traits§

ExceptionHandler
Trait for custom exception handlers