exceptions
Custom exceptions for sparkwheel with source location tracking and helpful error messages.
BaseError
Bases: Exception
Base exception for sparkwheel with rich error context.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
The error message |
|
source_location |
Optional location in config file where error occurred |
|
suggestion |
Optional helpful suggestion for fixing the error |
Source code in src/sparkwheel/utils/exceptions.py
_format_message()
Format error message with source location and suggestions.
Critical info (file:line) is on the first line for Rich compatibility, since Rich's traceback only shows the first line of exception messages.
Source code in src/sparkwheel/utils/exceptions.py
_get_config_snippet()
Extract and format a code snippet from the config file.
Source code in src/sparkwheel/utils/exceptions.py
CircularReferenceError
ConfigKeyError
Bases: BaseError
Raised when a config key is not found.
Supports smart suggestions and available keys display.
Source code in src/sparkwheel/utils/exceptions.py
__init__(message, source_location=None, suggestion=None, missing_key=None, available_keys=None, config_context=None)
Initialize ConfigKeyError with enhanced context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Error message |
required |
source_location
|
SourceLocation | None
|
Location where error occurred |
None
|
suggestion
|
str | None
|
Manual suggestion (optional) |
None
|
missing_key
|
str | None
|
The key that wasn't found |
None
|
available_keys
|
list[str] | None
|
List of available keys for suggestions |
None
|
config_context
|
dict[str, Any] | None
|
The config dict where the key wasn't found (for displaying available keys) |
None
|
Source code in src/sparkwheel/utils/exceptions.py
_generate_suggestion()
Generate smart suggestion with typo detection and available keys.
Source code in src/sparkwheel/utils/exceptions.py
ConfigMergeError
Bases: BaseError
Raised when configuration merge operation fails.
This is typically raised when using operators (= or ~) incorrectly: - Using ~ on a non-existent key - Using ~ with invalid value (must be null, empty, or list) - Type mismatch during merge (e.g., trying to merge dict into list)
Source code in src/sparkwheel/utils/exceptions.py
EvaluationError
FrozenConfigError
Bases: BaseError
Raised when attempting to modify a frozen config.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Error description |
|
field_path |
Path that was attempted to modify |
Source code in src/sparkwheel/utils/exceptions.py
InstantiationError
ModuleNotFoundError
SourceLocation
dataclass
Tracks the source location of a config item.