exceptions.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. """
  2. The driver exception classes here include all named exceptions required by th DB API 2.0 specification. It's not clear
  3. how useful that naming convention is, but the convention is used for potential improved compatibility with other
  4. libraries. In most cases docstring are taken from the DBIApi 2.0 documentation
  5. """
  6. class ClickHouseError(Exception):
  7. """Exception related to operation with ClickHouse."""
  8. # pylint: disable=redefined-builtin
  9. class Warning(Warning, ClickHouseError):
  10. """Exception raised for important warnings like data truncations
  11. while inserting, etc."""
  12. class Error(ClickHouseError):
  13. """Exception that is the base class of all other error exceptions
  14. (not Warning)."""
  15. class InterfaceError(Error):
  16. """Exception raised for errors that are related to the database
  17. interface rather than the database itself."""
  18. class DatabaseError(Error):
  19. """Exception raised for errors that are related to the
  20. database."""
  21. class DataError(DatabaseError):
  22. """Exception raised for errors that are due to problems with the
  23. processed data like division by zero, numeric value out of range,
  24. etc."""
  25. class OperationalError(DatabaseError):
  26. """Exception raised for errors that are related to the database's
  27. operation and not necessarily under the control of the programmer,
  28. e.g. an unexpected disconnect occurs, the data source name is not
  29. found, a transaction could not be processed, a memory allocation
  30. error occurred during processing, etc."""
  31. class IntegrityError(DatabaseError):
  32. """Exception raised when the relational integrity of the database
  33. is affected, e.g. a foreign key check fails, duplicate key,
  34. etc."""
  35. class InternalError(DatabaseError):
  36. """Exception raised when the database encounters an internal
  37. error, e.g. the cursor is not valid anymore, the transaction is
  38. out of sync, etc."""
  39. class ProgrammingError(DatabaseError):
  40. """Exception raised for programming errors, e.g. table not found
  41. or already exists, syntax error in the SQL statement, wrong number
  42. of parameters specified, etc."""
  43. class NotSupportedError(DatabaseError):
  44. """Exception raised in case a method or database API was used
  45. which is not supported by the database, e.g. requesting a
  46. .rollback() on a connection that does not support transaction or
  47. has transactions turned off."""
  48. class StreamClosedError(ProgrammingError):
  49. """Exception raised when a stream operation is executed on a closed stream."""
  50. def __init__(self):
  51. super().__init__('Executing a streaming operation on a closed stream')
  52. class StreamCompleteException(Exception):
  53. """ Internal exception used to indicate the end of a ClickHouse query result stream."""
  54. class StreamFailureError(Exception):
  55. """ Stream failed unexpectedly """