error.py (1707B)
1""" 2AQMP Error Classes 3 4This package seeks to provide semantic error classes that are intended 5to be used directly by clients when they would like to handle particular 6semantic failures (e.g. "failed to connect") without needing to know the 7enumeration of possible reasons for that failure. 8 9AQMPError serves as the ancestor for all exceptions raised by this 10package, and is suitable for use in handling semantic errors from this 11library. In most cases, individual public methods will attempt to catch 12and re-encapsulate various exceptions to provide a semantic 13error-handling interface. 14 15.. admonition:: AQMP Exception Hierarchy Reference 16 17 | `Exception` 18 | +-- `AQMPError` 19 | +-- `ConnectError` 20 | +-- `StateError` 21 | +-- `ExecInterruptedError` 22 | +-- `ExecuteError` 23 | +-- `ListenerError` 24 | +-- `ProtocolError` 25 | +-- `DeserializationError` 26 | +-- `UnexpectedTypeError` 27 | +-- `ServerParseError` 28 | +-- `BadReplyError` 29 | +-- `GreetingError` 30 | +-- `NegotiationError` 31""" 32 33 34class AQMPError(Exception): 35 """Abstract error class for all errors originating from this package.""" 36 37 38class ProtocolError(AQMPError): 39 """ 40 Abstract error class for protocol failures. 41 42 Semantically, these errors are generally the fault of either the 43 protocol server or as a result of a bug in this library. 44 45 :param error_message: Human-readable string describing the error. 46 """ 47 def __init__(self, error_message: str): 48 super().__init__(error_message) 49 #: Human-readable error message, without any prefix. 50 self.error_message: str = error_message