exceptions ¶
Custom Exceptions for Tux Bot.
This module defines all custom exception classes used throughout the Tux Discord bot, including database errors, permission errors, API errors, and validation errors.
Classes:
-
TuxError–Base exception for all Tux-specific errors.
-
TuxConfigurationError–Raised when there's a configuration issue.
-
TuxRuntimeError–Raised when there's a runtime issue.
-
TuxDatabaseError–Base exception for database-related errors.
-
TuxDatabaseConnectionError–Raised when database connection fails.
-
TuxDatabaseMigrationError–Raised when database migration fails.
-
TuxDatabaseQueryError–Raised when a database query fails.
-
TuxPermissionError–Base exception for permission-related errors.
-
TuxPermissionLevelError–Raised when a user doesn't have the required permission rank.
-
TuxAppCommandPermissionLevelError–Raised when a user doesn't have the required permission rank for an app command.
-
TuxPermissionDeniedError–Raised when a user doesn't have permission to run a command (dynamic system).
-
TuxAPIError–Base exception for API-related errors.
-
TuxAPIConnectionError–Raised when there's an issue connecting to an external API.
-
TuxAPIRequestError–Raised when an API request fails with a specific status code.
-
TuxAPIResourceNotFoundError–Raised when an API request results in a 404 or similar resource not found error.
-
TuxAPIPermissionError–Raised when an API request fails due to permissions (e.g., 403 Forbidden).
-
TuxCodeExecutionError–Base exception for code execution errors.
-
TuxMissingCodeError–Raised when no code is provided for execution.
-
TuxInvalidCodeFormatError–Raised when code format is invalid.
-
TuxUnsupportedLanguageError–Raised when the specified language is not supported.
-
TuxCompilationError–Raised when code compilation fails.
-
TuxServiceError–Base exception for service-related errors.
-
TuxCogLoadError–Raised when a cog fails to load.
-
TuxHotReloadError–Base exception for hot reload errors.
-
TuxDependencyResolutionError–Raised when dependency resolution fails.
-
TuxFileWatchError–Raised when file watching fails.
-
TuxModuleReloadError–Raised when module reloading fails.
-
TuxHotReloadConfigurationError–Raised when hot reload configuration is invalid.
Functions:
-
handle_gather_result–Handle a result from asyncio.gather with return_exceptions=True.
-
handle_case_result–Handle a case result from asyncio.gather with return_exceptions=True.
Classes¶
TuxDatabaseConnectionError ¶
TuxDatabaseConnectionError(
message: str = "Database connection failed", original_error: Exception | None = None
)
Bases: TuxDatabaseError
Raised when database connection fails.
Initialize the database connection error.
Parameters:
-
message(str, default:'Database connection failed') –Error message, by default "Database connection failed".
-
original_error(Exception, default:None) –The original exception that caused this error, by default None.
Functions¶
TuxDatabaseMigrationError ¶
Bases: TuxDatabaseError
Raised when database migration fails.
TuxDatabaseQueryError ¶
Bases: TuxDatabaseError
Raised when a database query fails.
TuxPermissionLevelError ¶
TuxPermissionLevelError(permission: str)
Bases: TuxPermissionError
Raised when a user doesn't have the required permission rank.
Initialize the permission level error.
Parameters:
-
permission(str) –The name of the required permission that was missing.
Functions¶
TuxAppCommandPermissionLevelError ¶
TuxAppCommandPermissionLevelError(permission: str)
Bases: TuxPermissionError
Raised when a user doesn't have the required permission rank for an app command.
Initialize the app command permission level error.
Parameters:
-
permission(str) –The name of the required permission that was missing for the app command.
Functions¶
TuxPermissionDeniedError ¶
TuxPermissionDeniedError(
required_rank: int, user_rank: int, command_name: str | None = None
)
Bases: TuxPermissionError
Raised when a user doesn't have permission to run a command (dynamic system).
Initialize the permission denied error.
Parameters:
-
required_rank(int) –The minimum permission rank required to run the command.
-
user_rank(int) –The actual permission rank of the user.
-
command_name(str, default:None) –The name of the command that was attempted, by default None.
Functions¶
TuxAPIConnectionError ¶
Bases: TuxAPIError
Raised when there's an issue connecting to an external API.
Initialize the API connection error.
Parameters:
-
service_name(str) –Name of the service that failed to connect.
-
original_error(Exception) –The original exception that caused the connection failure.
Functions¶
TuxAPIRequestError ¶
Bases: TuxAPIError
Raised when an API request fails with a specific status code.
Initialize the API request error.
Parameters:
-
service_name(str) –Name of the service that the request failed for.
-
status_code(int) –HTTP status code of the failed request.
-
reason(str) –Reason for the request failure.
Functions¶
TuxAPIResourceNotFoundError ¶
TuxAPIResourceNotFoundError(
service_name: str, resource_identifier: str, status_code: int = 404
)
Bases: TuxAPIRequestError
Raised when an API request results in a 404 or similar resource not found error.
Initialize the API resource not found error.
Parameters:
-
service_name(str) –Name of the service that was queried.
-
resource_identifier(str) –Identifier of the resource that was not found.
-
status_code(int, default:404) –HTTP status code, by default 404.
Functions¶
TuxAPIPermissionError ¶
Bases: TuxAPIRequestError
Raised when an API request fails due to permissions (e.g., 403 Forbidden).
Initialize the API permission error.
Parameters:
-
service_name(str) –Name of the service that rejected the request.
-
status_code(int, default:403) –HTTP status code, by default 403.
Functions¶
TuxMissingCodeError ¶
TuxMissingCodeError()
TuxInvalidCodeFormatError ¶
TuxInvalidCodeFormatError()
TuxUnsupportedLanguageError ¶
Bases: TuxCodeExecutionError
Raised when the specified language is not supported.
Initialize with language-specific error message.
Parameters:
-
language(str) –The unsupported language that was requested.
-
supported_languages(list[str]) –List of supported language names.
Functions¶
TuxCompilationError ¶
TuxCompilationError()
TuxCogLoadError ¶
Bases: TuxServiceError
Raised when a cog fails to load.
TuxHotReloadError ¶
Bases: TuxServiceError
Base exception for hot reload errors.
TuxDependencyResolutionError ¶
Bases: TuxHotReloadError
Raised when dependency resolution fails.
TuxFileWatchError ¶
Bases: TuxHotReloadError
Raised when file watching fails.
TuxModuleReloadError ¶
Bases: TuxHotReloadError
Raised when module reloading fails.
TuxHotReloadConfigurationError ¶
Bases: TuxHotReloadError
Raised when hot reload configuration is invalid.
Functions¶
handle_gather_result ¶
handle_gather_result(result: T | BaseException, expected_type: type[T]) -> T
Handle a result from asyncio.gather with return_exceptions=True.
Parameters:
-
result(T | BaseException) –The result from asyncio.gather
-
expected_type(type[T]) –The expected type of the result
Returns:
-
T–The result if it matches the expected type
Raises:
-
TypeError–If the result is not of the expected type
handle_case_result ¶
handle_case_result(case_result: Case | BaseException) -> Case
Handle a case result from asyncio.gather with return_exceptions=True.
Parameters:
-
case_result(Case | BaseException) –The case result from asyncio.gather
Returns:
-
Case–The case if valid