1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
from openleadr.enums import STATUS_CODES
class ProtocolError(Exception):
pass
class FingerprintMismatch(Exception):
pass
class HTTPError(Exception):
def __init__(self, status=500, description=None):
super().__init__()
self.response_code = status
self.response_description = description
class OutOfSequenceError(ProtocolError):
def __init__(self, description='OUT OF SEQUENCE'):
super().__init__()
self.response_code = STATUS_CODES.OUT_OF_SEQUENCE
self.response_description = description
class NotAllowedError(ProtocolError):
def __init__(self, description='NOT ALLOWED'):
super().__init__()
self.response_code = STATUS_CODES.NOT_ALLOWED
self.response_description = description
class InvalidIdError(ProtocolError):
def __init__(self, description='INVALID ID'):
super().__init__()
self.response_code = STATUS_CODES.INVALID_ID
self.response_description = description
class NotRecognizedError(ProtocolError):
def __init__(self, description='NOT RECOGNIZED'):
super().__init__()
self.response_code = STATUS_CODES.NOT_RECOGNIZED
self.response_description = description
class InvalidDataError(ProtocolError):
def __init__(self, description='INVALID DATA'):
super().__init__()
self.response_code = STATUS_CODES.INVALID_DATA
self.response_description = description
class ComplianceError(ProtocolError):
def __init__(self, description='COMPLIANCE ERROR'):
super().__init__()
self.response_code = STATUS_CODES.COMPLIANCE_ERROR
self.response_description = description
class SignalNotSupportedError(ProtocolError):
def __init__(self, description='SIGNAL NOT SUPPORTED'):
super().__init__()
self.response_code = STATUS_CODES.SIGNAL_NOT_SUPPORTED
self.response_description = description
class ReportNotSupportedError(ProtocolError):
def __init__(self, description='REPORT NOT SUPPORTED'):
super().__init__()
self.response_code = STATUS_CODES.REPORT_NOT_SUPPORTED
self.response_description = description
class TargetMismatchError(ProtocolError):
def __init__(self, description='TARGET MISMATCH'):
super().__init__()
self.response_code = STATUS_CODES.TARGET_MISMATCH
self.response_description = description
class NotRegisteredOrAuthorizedError(ProtocolError):
def __init__(self, description='NOT REGISTERED OR AUTHORIZED'):
super().__init__()
self.response_code = STATUS_CODES.NOT_REGISTERED_OR_AUTHORIZED
self.response_description = description
class DeploymentError(ProtocolError):
def __init__(self, description='DEPLOYMENT ERROR OR OTHER ERROR'):
super().__init__()
self.response_code = STATUS_CODES.DEPLOYMENT_ERROR_OR_OTHER_ERROR
self.response_description = description
# Flow-control based Exceptions
class RequestReregistration(Exception):
def __init__(self, ven_id=None):
super().__init__()
self.ven_id = ven_id
class SendEmptyHTTPResponse(Exception):
pass
|