Files
Pterodisbot/exceptions.py
T
k.eaven 346e6d9604
CI/CD Pipeline / Unit Tests (Python 3.11) (push) Successful in 29s
CI/CD Pipeline / Unit Tests (Python 3.12) (push) Successful in 30s
CI/CD Pipeline / Code Quality & Linting (push) Successful in 23s
CI/CD Pipeline / Unit Tests (Python 3.13) (push) Successful in 27s
CI/CD Pipeline / Integration Tests (push) Successful in 21s
CI/CD Pipeline / Security Scanning (push) Successful in 2m16s
CI/CD Pipeline / Generate Test Report (push) Successful in 4s
CI/CD Pipeline / Build Docker Image (push) Successful in 44s
CI/CD Pipeline / CI/CD Pipeline Status (push) Successful in 2s
Update: Major code refactor for modular extensibility
2026-10-24 10:58:01 +00:00

84 lines
1.6 KiB
Python

"""
Custom Exception Classes
Defines application-specific exceptions for better error handling
and clearer error messages throughout the codebase.
"""
class PterodisBotError(Exception):
"""Base exception class for all PterodisBot errors."""
pass
class ConfigValidationError(PterodisBotError):
"""
Raised when configuration validation fails.
Contains detailed error messages for all validation failures.
"""
pass
class APIError(PterodisBotError):
"""
Raised when an API request fails.
Attributes:
endpoint: The API endpoint that failed
status_code: HTTP status code if available
message: Error message from the API
"""
def __init__(
self,
message: str,
endpoint: str = "",
status_code: int = 0,
) -> None:
super().__init__(message)
self.endpoint = endpoint
self.status_code = status_code
self.message = message
class ServerNotFoundError(PterodisBotError):
"""
Raised when a requested server is not found in the panel.
"""
pass
class PermissionError(PterodisBotError):
"""
Raised when a user lacks required permissions for an action.
"""
pass
class EmbedNotFoundError(PterodisBotError):
"""
Raised when a tracked embed message is not found in Discord.
"""
pass
class MetricsError(PterodisBotError):
"""
Raised when metrics graph generation fails.
"""
pass
class ConfigurationError(PterodisBotError):
"""
Raised when there's a configuration issue not caught during startup validation.
"""
pass