"""Exception classes for Power Switch Pro library."""
[docs]
class PowerSwitchError(Exception):
"""Base exception for all Power Switch Pro errors."""
pass
[docs]
class AuthenticationError(PowerSwitchError):
"""Raised when authentication fails."""
pass
[docs]
class ConnectionError(PowerSwitchError):
"""Raised when connection to device fails."""
pass
[docs]
class APIError(PowerSwitchError):
"""Raised when API returns an error response."""
[docs]
def __init__(self, message, status_code=None, response=None):
"""
Initialize API error.
Args:
message: Error message
status_code: HTTP status code
response: Full response object
"""
super().__init__(message)
self.status_code = status_code
self.response = response
[docs]
class ValidationError(PowerSwitchError):
"""Raised when input validation fails."""
pass
[docs]
class ResourceNotFoundError(APIError):
"""Raised when a requested resource is not found."""
pass
[docs]
class ConflictError(APIError):
"""Raised when there is a conflict (409 status)."""
pass