sok.core.exceptions
Custom exceptions for the S.O.K. project.
This module defines an exception hierarchy to improve error handling and facilitate debugging.
APIAuthenticationError
class APIAuthenticationError(message: str, api_name: str = 'unknown')Bases: APIError
Exception raised on authentication errors.
Initialize an API authentication error.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
message | str | Error description. | |
api_name | str | 'unknown' | Name of the API with auth issues. |
APIConnectionError
class APIConnectionError(message: str, api_name: str = 'unknown')Bases: APIError
Exception raised on API connection errors.
Initialize an API connection error.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
message | str | Error description. | |
api_name | str | 'unknown' | Name of the API with connection issues. |
APIError
class APIError(message: str, api_name: str = 'unknown')Bases: SOKBaseError
Base exception for API errors.
Initialize an API error.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
message | str | Error description. | |
api_name | str | 'unknown' | Name of the API that raised the error. |
Attributes
| Name |
|---|
api_name |
APINotFoundError
class APINotFoundError(message: str, api_name: str = 'unknown')Bases: APIError
Exception raised when the requested API is not found.
Initialize an API not found error.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
message | str | Error description. | |
api_name | str | 'unknown' | Name of the missing API. |
APIRateLimitError
class APIRateLimitError( message: str, api_name: str = 'unknown', retry_after: int = 0,)Bases: APIError
Exception raised when API rate limit is exceeded.
Initialize an API rate limit error.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
message | str | Error description. | |
api_name | str | 'unknown' | Name of the rate-limited API. |
retry_after | int | 0 | Seconds to wait before retrying. |
Attributes
| Name |
|---|
retry_after |
APIResponseError
class APIResponseError( message: str, api_name: str = 'unknown', status: Optional[int] = None,)Bases: APIError
Exception raised on response parsing errors.
Initialize an API response error.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
message | str | Error description. | |
api_name | str | 'unknown' | Name of the API with response issues. |
status | Optional[int] | None | HTTP status of the response, if any. |
Attributes
| Name | Description |
|---|---|
status | HTTP status of the response, or None when the response could not be read. |
APITimeoutError
class APITimeoutError(message: str, api_name: str = 'unknown')Bases: APIError
Exception raised on API timeout.
Initialize an API timeout error.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
message | str | Error description. | |
api_name | str | 'unknown' | Name of the API that timed out. |
ConfigurationError
class ConfigurationErrorBases: SOKBaseError
Exception raised on configuration errors.
SourceFileNotFoundError
class FileNotFoundError(message: str, file_path: str = '')Bases: FileOperationError
Exception raised when a file is not found.
Initialize a file not found error.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
message | str | Error description. | |
file_path | str | '' | Path to the missing file. |
Attributes
| Name |
|---|
file_path |
FileOperationError
class FileOperationErrorBases: SOKBaseError
Base exception for file operation errors.
SourceFilePermissionError
class FilePermissionError(message: str, file_path: str = '')Bases: FileOperationError
Exception raised on permission errors.
Initialize a file permission error.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
message | str | Error description. | |
file_path | str | '' | Path to the file with permission issues. |
Attributes
| Name |
|---|
file_path |
MediaError
class MediaErrorBases: SOKBaseError
Base exception for media-related errors.
SourceMediaNotFoundError
class MediaNotFoundError(message: str)Bases: MediaError
Exception raised when a media item is not found.
Initialize a media not found error.
Parameters
| Name | Type | Description |
|---|---|---|
message | str | Error description. |
MissingConfigurationError
class MissingConfigurationError(message: str, config_key: str = '')Bases: ConfigurationError
Exception raised when a required configuration is missing.
Initialize a missing configuration error.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
message | str | Error description. | |
config_key | str | '' | Name of the missing configuration key. |
Attributes
| Name |
|---|
config_key |
SOKBaseError
class SOKBaseErrorBases: Exception
Base class for all S.O.K. exceptions.
SourceUnsupportedMediaTypeError
class UnsupportedMediaTypeError(message: str)Bases: MediaError
Exception raised when the media type is not supported.
Initialize an unsupported media type error.
Parameters
| Name | Type | Description |
|---|---|---|
message | str | Error description. |