Skip to content

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

NameTypeDefaultDescription
messagestrError description.
api_namestr'unknown'Name of the API with auth issues.
Source

APIConnectionError

class APIConnectionError(message: str, api_name: str = 'unknown')

Bases: APIError

Exception raised on API connection errors.

Initialize an API connection error.

Parameters

NameTypeDefaultDescription
messagestrError description.
api_namestr'unknown'Name of the API with connection issues.
Source

APIError

class APIError(message: str, api_name: str = 'unknown')

Bases: SOKBaseError

Base exception for API errors.

Initialize an API error.

Parameters

NameTypeDefaultDescription
messagestrError description.
api_namestr'unknown'Name of the API that raised the error.
Source

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

NameTypeDefaultDescription
messagestrError description.
api_namestr'unknown'Name of the missing API.
Source

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

NameTypeDefaultDescription
messagestrError description.
api_namestr'unknown'Name of the rate-limited API.
retry_afterint0Seconds to wait before retrying.
Source

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

NameTypeDefaultDescription
messagestrError description.
api_namestr'unknown'Name of the API with response issues.
statusOptional[int]NoneHTTP status of the response, if any.
Source

Attributes

NameDescription
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

NameTypeDefaultDescription
messagestrError description.
api_namestr'unknown'Name of the API that timed out.
Source

ConfigurationError

class ConfigurationError

Bases: SOKBaseError

Exception raised on configuration errors.

Source

FileNotFoundError

class FileNotFoundError(message: str, file_path: str = '')

Bases: FileOperationError

Exception raised when a file is not found.

Initialize a file not found error.

Parameters

NameTypeDefaultDescription
messagestrError description.
file_pathstr''Path to the missing file.
Source

Attributes

Name
file_path

FileOperationError

class FileOperationError

Bases: SOKBaseError

Base exception for file operation errors.

Source

FilePermissionError

class FilePermissionError(message: str, file_path: str = '')

Bases: FileOperationError

Exception raised on permission errors.

Initialize a file permission error.

Parameters

NameTypeDefaultDescription
messagestrError description.
file_pathstr''Path to the file with permission issues.
Source

Attributes

Name
file_path

MediaError

class MediaError

Bases: SOKBaseError

Base exception for media-related errors.

Source

MediaNotFoundError

class MediaNotFoundError(message: str)

Bases: MediaError

Exception raised when a media item is not found.

Initialize a media not found error.

Parameters

NameTypeDescription
messagestrError description.
Source

MissingConfigurationError

class MissingConfigurationError(message: str, config_key: str = '')

Bases: ConfigurationError

Exception raised when a required configuration is missing.

Initialize a missing configuration error.

Parameters

NameTypeDefaultDescription
messagestrError description.
config_keystr''Name of the missing configuration key.
Source

Attributes

Name
config_key

SOKBaseError

class SOKBaseError

Bases: Exception

Base class for all S.O.K. exceptions.

Source

UnsupportedMediaTypeError

class UnsupportedMediaTypeError(message: str)

Bases: MediaError

Exception raised when the media type is not supported.

Initialize an unsupported media type error.

Parameters

NameTypeDescription
messagestrError description.
Source
Built with Kiln