Extractor strategy
Base extraction strategy for provider-specific error parsing.
This module defines the base interface that all provider-specific extraction strategies must implement. It provides default implementations for common extraction methods and defines the 4-stage resolution pipeline structure.
References
NONE
BaseExtractionStrategy
Bases: ABC
Base extraction strategy for provider-specific error parsing.
This class provides a self-contained error parsing system with a 4-stage resolution pipeline. Subclasses define provider-specific mappings and extraction logic.
The 4-stage resolution pipeline
- Response detail mapping (error codes/types)
- Message pattern matching (regex)
- HTTP status code mapping
- Exception type mapping (fully qualified class name)
Attributes:
| Name | Type | Description |
|---|---|---|
response_detail_mapping |
dict[str, type[BaseInvokerError]]
|
Maps provider error codes/types to BaseInvokerError subclasses. |
message_pattern_mapping |
dict[str, type[BaseInvokerError]]
|
Maps regex patterns to BaseInvokerError subclasses. |
status_code_mapping |
dict[int, type[BaseInvokerError]]
|
Maps HTTP status codes to BaseInvokerError subclasses. |
exception_mapping |
dict[str, type[BaseInvokerError]]
|
Maps fully qualified exception class names to BaseInvokerError subclasses. |
parse(error, class_name)
Parse error using the 4-stage resolution pipeline.
This method orchestrates the error parsing process by attempting each stage of the resolution pipeline in order until a match is found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
Exception
|
The raw provider error. |
required |
class_name
|
str
|
Invoker class name for error context. |
required |
Returns:
| Type | Description |
|---|---|
BaseInvokerError | None
|
BaseInvokerError | None: Parsed and classified error if a match is found, None if no stage could resolve the error. |
ErrorResolverType
Bases: StrEnum
Error resolver type for the 4-stage resolution pipeline.
ExtendedHTTPStatus
Bases: IntEnum
HTTP status codes outside of the standard HTTPStatus enum.
Attributes:
| Name | Type | Description |
|---|---|---|
SERVICE_OVERLOADED |
int
|
HTTP status code for service overloaded. |