error_handler¶
error_handler ¶
Error handling system with configurable policies.
Implements Strategy pattern for different error handling approaches.
ErrorAction ¶
Bases: str, Enum
Actions to take on errors.
ErrorDecision
dataclass
¶
ErrorDecision(action: ErrorAction, default_value: Any = None, retry_count: int = 0, context: dict[str, Any] | None = None)
Decision on how to handle an error.
ErrorHandler ¶
ErrorHandler(policy: ErrorPolicy = ErrorPolicy.SKIP, max_retries: int = 3, default_value: Any = None, default_value_factory: Callable[[], Any] | None = None)
Policy-based error handling (orchestrates retry/skip/fail decisions).
Scope: Stage execution errors and pipeline-level error handling Policies: SKIP, FAIL, RETRY (delegates to RetryHandler for execution) Use when: Configuring how the pipeline handles errors
Policy Behaviors: - SKIP: Log error and skip the row (continue processing) - FAIL: Raise error and stop pipeline - RETRY: Retry the operation (delegates to RetryHandler) - DEFAULT: Return a default value on error
Example
handler = ErrorHandler(policy=ErrorPolicy.RETRY, max_retries=3) decision = handler.handle_error(exception, context)
See Also: - RetryHandler: Executes the actual retry logic - Pipeline._auto_retry_failed_rows(): Row-level quality retry - docs/architecture/decisions/ADR-006-retry-levels.md
Design Note
ErrorHandler decides WHAT to do (policy) RetryHandler decides HOW to do it (exponential backoff)
Initialize error handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
ErrorPolicy
|
Error handling policy |
SKIP
|
max_retries
|
int
|
Maximum retry attempts |
3
|
default_value
|
Any
|
Static default value (or use default_value_factory) |
None
|
default_value_factory
|
Callable[[], Any] | None
|
Function to generate default values |
None
|
Source code in ondine/core/error_handler.py
handle_error ¶
Decide how to handle an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
Exception
|
The exception that occurred |
required |
context
|
dict[str, Any]
|
Error context (row_index, stage, etc.) |
required |
attempt
|
int
|
Current attempt number |
1
|
Returns:
| Type | Description |
|---|---|
ErrorDecision
|
ErrorDecision with action to take |
Source code in ondine/core/error_handler.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
should_retry ¶
Determine if error should be retried.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
Exception
|
The exception |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if retriable |