Exceptions
Custom exceptions for dataset handling and template processing.
This module defines specialized exception classes for handling errors that can occur during dataset loading, template processing, and data transformation operations.
Reviewer
- Muhammad Afif Al Hawari (muhammad.a.a.hawari@gdplabs.id)
References
NONE
DataSourceNotProvidedError
Bases: DataLoaderError
Raised when no valid data source is specified in the experiment arguments.
This exception is thrown when the UnifiedDataLoader cannot determine which data source to use because the experiment arguments do not contain valid specifications for any supported data source type (e.g., CSV or Google Sheets).
MissingColumnsError(missing_columns, row_index=None)
Bases: TemplateProcessingError
Raised when required columns are missing from the dataframe row.
This exception is raised when the template processor encounters a dataframe row that is missing one or more columns that are required for template formatting. It provides detailed information about which columns are missing and optionally the row index where the error occurred.
Initialize the MissingColumnsError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
missing_columns |
list[str]
|
List of missing column names. |
required |
row_index |
Optional[int]
|
Index of the row where the error occurred. Defaults to None. |
None
|
TemplateFormattingError(missing_variable, template, row_index=None)
Bases: TemplateProcessingError
Raised when template formatting fails due to missing variables.
This exception is raised when a template string contains placeholder variables that cannot be found in the provided data. It provides detailed information about the missing variable, the template where it occurred, and optionally the row index for better debugging.
Initialize the TemplateFormattingError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
missing_variable |
str
|
Name of the missing template variable. |
required |
template |
str
|
The template string where the error occurred. |
required |
row_index |
Optional[int]
|
Index of the row where the error occurred. Defaults to None. |
None
|
TemplateProcessingError
Bases: Exception
Base exception for template processing errors.
This exception serves as the base class for all template-related processing errors. It provides a common interface for handling various types of failures that can occur during template processing operations.