errors.py 1005 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from __future__ import annotations
  2. class MySQLBaseException(Exception):
  3. """Base exception for this mysql helper library."""
  4. def __init__(
  5. self,
  6. message: str,
  7. error_code: str | None = None,
  8. original_error: Exception | None = None,
  9. ):
  10. super().__init__(message)
  11. self.message = message
  12. self.error_code = error_code
  13. self.original_error = original_error
  14. class MySQLConnectionError(MySQLBaseException):
  15. """Raised when connecting to MySQL fails."""
  16. class MySQLConfigError(MySQLBaseException):
  17. """Raised when configuration is invalid."""
  18. class MySQLQueryError(MySQLBaseException):
  19. """Raised when executing a SQL statement fails."""
  20. class MySQLTransactionError(MySQLBaseException):
  21. """Raised when a transaction fails."""
  22. class MySQLPoolError(MySQLBaseException):
  23. """Raised when connection pool fails."""
  24. class MySQLValidationError(MySQLBaseException):
  25. """Raised when input data validation fails."""