iqrfpy.exceptions
Exceptions module.
This module contains exceptions classes for library-wide use.
1"""Exceptions module. 2 3This module contains exceptions classes for library-wide use. 4""" 5 6from typing import Optional 7 8__all__ = [ 9 'RequestNadrInvalidError', 10 'RequestPnumInvalidError', 11 'RequestPcmdInvalidError', 12 'RequestHwpidInvalidError', 13 'RequestParameterInvalidValueError', 14 'DpaConfirmationPacketError', 15 'DpaConfirmationPacketLengthError', 16 'DpaResponsePacketLengthError', 17 'JsonMsgidMissingError', 18 'JsonMTypeMissingError', 19 'JsonNadrMissingError', 20 'JsonHwpidMissingError', 21 'JsonRCodeMissingError', 22 'JsonDpaValueMissingError', 23 'JsonResultMissingError', 24 'JsonStatusMissingError', 25 'InvalidPeripheralValueError', 26 'InvalidPeripheralCommandValueError', 27 'UnsupportedPeripheralError', 28 'UnsupportedPeripheralCommandError', 29 'UnsupportedMessageTypeError', 30 'TransportNotConnectedError', 31 'DpaRequestTimeoutError', 32 'JsonRequestTimeoutError', 33 'JsonResponseNotSupportedError', 34 'JsonGenericDataMissingError', 35 'MessageNotReceivedError', 36 'UnknownSensorTypeError', 37 'ResponseFactoryRegisterError', 38] 39 40 41class RequestNadrInvalidError(ValueError): 42 """Invalid NADR value. 43 44 This error is raised whenever a request object receives 45 address that is out of allowed range ([C]: 0, [N]: 1-239). 46 """ 47 48 49class RequestPnumInvalidError(ValueError): 50 """Invalid PNUM value. 51 52 This error is raised whenever a request object receives 53 PNUM that is out of allowed range (0-255 / 0x00-0xFF). 54 """ 55 56 57class RequestPcmdInvalidError(ValueError): 58 """Invalid PCMD value. 59 60 This error is raised whenever a request object receives 61 PCMD that is out of allowed range (0-255 / 0x00-0xFF). 62 """ 63 64 65class RequestHwpidInvalidError(ValueError): 66 """Invalid HWPID value. 67 68 This error is raised whenever a request object receives 69 HWPID that is out of allowed range (0-65535 / 0x0000-0xFFFF). 70 """ 71 72 73class RequestParameterInvalidValueError(ValueError): 74 """Invalid request parameter value. 75 76 This error is raised whenever a request object receives 77 a parameter with value outside of it's defined domain. 78 """ 79 80 81class DpaConfirmationPacketError(ValueError): 82 """Invalid DPA confirmation packet. 83 84 This error is raised whenever a packet does not meet requirements 85 of a DPA confirmation packet. 86 """ 87 88 89class DpaConfirmationPacketLengthError(ValueError): 90 """Invalid DPA confirmation packet length. 91 92 This error is raised whenever a DPA confirmation packet length does 93 not match expected packet length. 94 """ 95 96 97class DpaResponsePacketLengthError(ValueError): 98 """Invalid DPA response packet length. 99 100 This error is raised whenever a DPA response packet length 101 does not match the expected packet length of a specific DPA response. 102 """ 103 104 105class JsonMsgidMissingError(KeyError): 106 """msgId property missing. 107 108 This error is raised whenever a json response object 109 does not contain the msgId property. 110 """ 111 112 113class JsonMTypeMissingError(KeyError): 114 """mType property missing. 115 116 This error is raised whenever a json response object 117 does not contain the mType property. 118 """ 119 120 121class JsonNadrMissingError(KeyError): 122 """nAdr property missing. 123 124 This error is raised whenever a json response object 125 does not contain the nAdr property. 126 """ 127 128 129class JsonHwpidMissingError(KeyError): 130 """hwpId property missing. 131 132 This error is raised whenever a json response object 133 does not contain the hwpId property. 134 """ 135 136 137class JsonRCodeMissingError(KeyError): 138 """rCode property missing. 139 140 This error is raised whenever a json response object 141 does not contain the rCode property. 142 """ 143 144 145class JsonDpaValueMissingError(KeyError): 146 """dpaVal property missing. 147 148 This error is raised whenever a json response object 149 does not contain the dpaVal property. 150 """ 151 152 153class JsonResultMissingError(KeyError): 154 """result property missing. 155 156 This error is raised whenever a json response object 157 does not contain the result property. 158 """ 159 160 161class JsonStatusMissingError(KeyError): 162 """status property missing. 163 164 This error is raised whenever a json response object 165 does not contain the status property. 166 """ 167 168 169class JsonGenericDataMissingError(KeyError): 170 """rData property missing. 171 172 This error is raised when a generic json response object 173 does not contain the rData property. 174 """ 175 176 177class InvalidPeripheralValueError(ValueError): 178 """Invalid peripheral value. 179 180 This error is raised whenever a peripheral parameter value is out 181 of defined range. 182 """ 183 184 185class InvalidPeripheralCommandValueError(ValueError): 186 """Invalid peripheral command value. 187 188 This error is raised whenever a peripheral command parameter value is out 189 of defined range. 190 """ 191 192 193class UnsupportedPeripheralError(ValueError): 194 """Peripheral unknown or unsupported. 195 196 This error is raised whenever a peripheral parameter value is valid, 197 but not recognized as a known and supported peripheral. 198 """ 199 200 201class UnsupportedPeripheralCommandError(ValueError): 202 """Peripheral command unknown or unsupported. 203 204 This error is raised whenever a peripheral parameter command value is valid, 205 but not recognized as a known and supported peripheral command. 206 """ 207 208 209class UnsupportedMessageTypeError(ValueError): 210 """Message type unknown or unsupported. 211 212 This error is raised whenever a message type parameter is used 213 to determine a value, but the message type parameter value is not 214 recognized as a known and supported message type. 215 """ 216 217 def __init__(self, message: str, msgid: Optional[str] = None): 218 """UnsupportedMessageTypeError constructor. 219 220 Args: 221 message (str): Error message. 222 msgid (str, optional): Message ID. Defaults to None. 223 """ 224 super().__init__(message) 225 self.msgid = msgid 226 227 228class TransportNotConnectedError(ConnectionError): 229 """Transport not connected. 230 231 This error is raised whenever a transport object is tasked 232 with sending a message while not being connected or having lost 233 connection. 234 """ 235 236 237class DpaRequestTimeoutError(TimeoutError): 238 """DPA request not handled or response not received. 239 240 This error is raised whenever transport does not receive a DPA response 241 within specified time. If JSON API is used, a JSON response is received, 242 but the contents indicate DPA timeout. 243 """ 244 245 246class JsonRequestTimeoutError(TimeoutError): 247 """JSON API response not received. 248 249 This error is raised whenever transport does not receive a JSON API 250 response within specified time. 251 """ 252 253 254class JsonResponseNotSupportedError(ValueError): 255 """JSON API response not supported. 256 257 This error is raised whenever transport receives a response message that is not supported, 258 but the message ID matches a request sent prior to the fact. 259 """ 260 261 262class MessageNotReceivedError(TimeoutError): 263 """Message not received. 264 265 This error is raised during parsing of a JSON API response 266 indicating that DPA response was not received. 267 """ 268 269 def __init__(self, message: str, msgid: Optional[str] = None): 270 """MessageNotReceivedError constructor. 271 272 Args: 273 message (str): Error message. 274 msgid (str, optional): Message ID. Defaults to None. 275 """ 276 super().__init__(message) 277 self.msgid = msgid 278 279 280class UnknownSensorTypeError(ValueError): 281 """Unknown or unsupported sensor type. 282 283 This error is raised when parsing Sensor data collected using regular or FRC requests 284 and the sensor type value is not recognized by the library. 285 """ 286 287 288class ResponseFactoryRegisterError(KeyError): 289 """Response factory cannot be registered. 290 291 This error is raised when a response factory is attempted to be registered under existing 292 combination of pnum and pcmd for DPA messages or existing message type for JSON API responses. 293 """
42class RequestNadrInvalidError(ValueError): 43 """Invalid NADR value. 44 45 This error is raised whenever a request object receives 46 address that is out of allowed range ([C]: 0, [N]: 1-239). 47 """
Invalid NADR value.
This error is raised whenever a request object receives address that is out of allowed range ([C]: 0, [N]: 1-239).
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
50class RequestPnumInvalidError(ValueError): 51 """Invalid PNUM value. 52 53 This error is raised whenever a request object receives 54 PNUM that is out of allowed range (0-255 / 0x00-0xFF). 55 """
Invalid PNUM value.
This error is raised whenever a request object receives PNUM that is out of allowed range (0-255 / 0x00-0xFF).
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
58class RequestPcmdInvalidError(ValueError): 59 """Invalid PCMD value. 60 61 This error is raised whenever a request object receives 62 PCMD that is out of allowed range (0-255 / 0x00-0xFF). 63 """
Invalid PCMD value.
This error is raised whenever a request object receives PCMD that is out of allowed range (0-255 / 0x00-0xFF).
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
66class RequestHwpidInvalidError(ValueError): 67 """Invalid HWPID value. 68 69 This error is raised whenever a request object receives 70 HWPID that is out of allowed range (0-65535 / 0x0000-0xFFFF). 71 """
Invalid HWPID value.
This error is raised whenever a request object receives HWPID that is out of allowed range (0-65535 / 0x0000-0xFFFF).
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
74class RequestParameterInvalidValueError(ValueError): 75 """Invalid request parameter value. 76 77 This error is raised whenever a request object receives 78 a parameter with value outside of it's defined domain. 79 """
Invalid request parameter value.
This error is raised whenever a request object receives a parameter with value outside of it's defined domain.
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
82class DpaConfirmationPacketError(ValueError): 83 """Invalid DPA confirmation packet. 84 85 This error is raised whenever a packet does not meet requirements 86 of a DPA confirmation packet. 87 """
Invalid DPA confirmation packet.
This error is raised whenever a packet does not meet requirements of a DPA confirmation packet.
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
90class DpaConfirmationPacketLengthError(ValueError): 91 """Invalid DPA confirmation packet length. 92 93 This error is raised whenever a DPA confirmation packet length does 94 not match expected packet length. 95 """
Invalid DPA confirmation packet length.
This error is raised whenever a DPA confirmation packet length does not match expected packet length.
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
98class DpaResponsePacketLengthError(ValueError): 99 """Invalid DPA response packet length. 100 101 This error is raised whenever a DPA response packet length 102 does not match the expected packet length of a specific DPA response. 103 """
Invalid DPA response packet length.
This error is raised whenever a DPA response packet length does not match the expected packet length of a specific DPA response.
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
106class JsonMsgidMissingError(KeyError): 107 """msgId property missing. 108 109 This error is raised whenever a json response object 110 does not contain the msgId property. 111 """
msgId property missing.
This error is raised whenever a json response object does not contain the msgId property.
Inherited Members
- builtins.KeyError
- KeyError
- builtins.BaseException
- with_traceback
- add_note
- args
114class JsonMTypeMissingError(KeyError): 115 """mType property missing. 116 117 This error is raised whenever a json response object 118 does not contain the mType property. 119 """
mType property missing.
This error is raised whenever a json response object does not contain the mType property.
Inherited Members
- builtins.KeyError
- KeyError
- builtins.BaseException
- with_traceback
- add_note
- args
122class JsonNadrMissingError(KeyError): 123 """nAdr property missing. 124 125 This error is raised whenever a json response object 126 does not contain the nAdr property. 127 """
nAdr property missing.
This error is raised whenever a json response object does not contain the nAdr property.
Inherited Members
- builtins.KeyError
- KeyError
- builtins.BaseException
- with_traceback
- add_note
- args
130class JsonHwpidMissingError(KeyError): 131 """hwpId property missing. 132 133 This error is raised whenever a json response object 134 does not contain the hwpId property. 135 """
hwpId property missing.
This error is raised whenever a json response object does not contain the hwpId property.
Inherited Members
- builtins.KeyError
- KeyError
- builtins.BaseException
- with_traceback
- add_note
- args
138class JsonRCodeMissingError(KeyError): 139 """rCode property missing. 140 141 This error is raised whenever a json response object 142 does not contain the rCode property. 143 """
rCode property missing.
This error is raised whenever a json response object does not contain the rCode property.
Inherited Members
- builtins.KeyError
- KeyError
- builtins.BaseException
- with_traceback
- add_note
- args
146class JsonDpaValueMissingError(KeyError): 147 """dpaVal property missing. 148 149 This error is raised whenever a json response object 150 does not contain the dpaVal property. 151 """
dpaVal property missing.
This error is raised whenever a json response object does not contain the dpaVal property.
Inherited Members
- builtins.KeyError
- KeyError
- builtins.BaseException
- with_traceback
- add_note
- args
154class JsonResultMissingError(KeyError): 155 """result property missing. 156 157 This error is raised whenever a json response object 158 does not contain the result property. 159 """
result property missing.
This error is raised whenever a json response object does not contain the result property.
Inherited Members
- builtins.KeyError
- KeyError
- builtins.BaseException
- with_traceback
- add_note
- args
162class JsonStatusMissingError(KeyError): 163 """status property missing. 164 165 This error is raised whenever a json response object 166 does not contain the status property. 167 """
status property missing.
This error is raised whenever a json response object does not contain the status property.
Inherited Members
- builtins.KeyError
- KeyError
- builtins.BaseException
- with_traceback
- add_note
- args
178class InvalidPeripheralValueError(ValueError): 179 """Invalid peripheral value. 180 181 This error is raised whenever a peripheral parameter value is out 182 of defined range. 183 """
Invalid peripheral value.
This error is raised whenever a peripheral parameter value is out of defined range.
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
186class InvalidPeripheralCommandValueError(ValueError): 187 """Invalid peripheral command value. 188 189 This error is raised whenever a peripheral command parameter value is out 190 of defined range. 191 """
Invalid peripheral command value.
This error is raised whenever a peripheral command parameter value is out of defined range.
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
194class UnsupportedPeripheralError(ValueError): 195 """Peripheral unknown or unsupported. 196 197 This error is raised whenever a peripheral parameter value is valid, 198 but not recognized as a known and supported peripheral. 199 """
Peripheral unknown or unsupported.
This error is raised whenever a peripheral parameter value is valid, but not recognized as a known and supported peripheral.
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
202class UnsupportedPeripheralCommandError(ValueError): 203 """Peripheral command unknown or unsupported. 204 205 This error is raised whenever a peripheral parameter command value is valid, 206 but not recognized as a known and supported peripheral command. 207 """
Peripheral command unknown or unsupported.
This error is raised whenever a peripheral parameter command value is valid, but not recognized as a known and supported peripheral command.
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
210class UnsupportedMessageTypeError(ValueError): 211 """Message type unknown or unsupported. 212 213 This error is raised whenever a message type parameter is used 214 to determine a value, but the message type parameter value is not 215 recognized as a known and supported message type. 216 """ 217 218 def __init__(self, message: str, msgid: Optional[str] = None): 219 """UnsupportedMessageTypeError constructor. 220 221 Args: 222 message (str): Error message. 223 msgid (str, optional): Message ID. Defaults to None. 224 """ 225 super().__init__(message) 226 self.msgid = msgid
Message type unknown or unsupported.
This error is raised whenever a message type parameter is used to determine a value, but the message type parameter value is not recognized as a known and supported message type.
218 def __init__(self, message: str, msgid: Optional[str] = None): 219 """UnsupportedMessageTypeError constructor. 220 221 Args: 222 message (str): Error message. 223 msgid (str, optional): Message ID. Defaults to None. 224 """ 225 super().__init__(message) 226 self.msgid = msgid
UnsupportedMessageTypeError constructor.
Arguments:
- message (str): Error message.
- msgid (str, optional): Message ID. Defaults to None.
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
229class TransportNotConnectedError(ConnectionError): 230 """Transport not connected. 231 232 This error is raised whenever a transport object is tasked 233 with sending a message while not being connected or having lost 234 connection. 235 """
Transport not connected.
This error is raised whenever a transport object is tasked with sending a message while not being connected or having lost connection.
Inherited Members
- builtins.ConnectionError
- ConnectionError
- builtins.OSError
- errno
- strerror
- filename
- filename2
- characters_written
- builtins.BaseException
- with_traceback
- add_note
- args
238class DpaRequestTimeoutError(TimeoutError): 239 """DPA request not handled or response not received. 240 241 This error is raised whenever transport does not receive a DPA response 242 within specified time. If JSON API is used, a JSON response is received, 243 but the contents indicate DPA timeout. 244 """
DPA request not handled or response not received.
This error is raised whenever transport does not receive a DPA response within specified time. If JSON API is used, a JSON response is received, but the contents indicate DPA timeout.
Inherited Members
- builtins.TimeoutError
- TimeoutError
- builtins.OSError
- errno
- strerror
- filename
- filename2
- characters_written
- builtins.BaseException
- with_traceback
- add_note
- args
247class JsonRequestTimeoutError(TimeoutError): 248 """JSON API response not received. 249 250 This error is raised whenever transport does not receive a JSON API 251 response within specified time. 252 """
JSON API response not received.
This error is raised whenever transport does not receive a JSON API response within specified time.
Inherited Members
- builtins.TimeoutError
- TimeoutError
- builtins.OSError
- errno
- strerror
- filename
- filename2
- characters_written
- builtins.BaseException
- with_traceback
- add_note
- args
255class JsonResponseNotSupportedError(ValueError): 256 """JSON API response not supported. 257 258 This error is raised whenever transport receives a response message that is not supported, 259 but the message ID matches a request sent prior to the fact. 260 """
JSON API response not supported.
This error is raised whenever transport receives a response message that is not supported, but the message ID matches a request sent prior to the fact.
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
170class JsonGenericDataMissingError(KeyError): 171 """rData property missing. 172 173 This error is raised when a generic json response object 174 does not contain the rData property. 175 """
rData property missing.
This error is raised when a generic json response object does not contain the rData property.
Inherited Members
- builtins.KeyError
- KeyError
- builtins.BaseException
- with_traceback
- add_note
- args
263class MessageNotReceivedError(TimeoutError): 264 """Message not received. 265 266 This error is raised during parsing of a JSON API response 267 indicating that DPA response was not received. 268 """ 269 270 def __init__(self, message: str, msgid: Optional[str] = None): 271 """MessageNotReceivedError constructor. 272 273 Args: 274 message (str): Error message. 275 msgid (str, optional): Message ID. Defaults to None. 276 """ 277 super().__init__(message) 278 self.msgid = msgid
Message not received.
This error is raised during parsing of a JSON API response indicating that DPA response was not received.
270 def __init__(self, message: str, msgid: Optional[str] = None): 271 """MessageNotReceivedError constructor. 272 273 Args: 274 message (str): Error message. 275 msgid (str, optional): Message ID. Defaults to None. 276 """ 277 super().__init__(message) 278 self.msgid = msgid
MessageNotReceivedError constructor.
Arguments:
- message (str): Error message.
- msgid (str, optional): Message ID. Defaults to None.
Inherited Members
- builtins.OSError
- errno
- strerror
- filename
- filename2
- characters_written
- builtins.BaseException
- with_traceback
- add_note
- args
281class UnknownSensorTypeError(ValueError): 282 """Unknown or unsupported sensor type. 283 284 This error is raised when parsing Sensor data collected using regular or FRC requests 285 and the sensor type value is not recognized by the library. 286 """
Unknown or unsupported sensor type.
This error is raised when parsing Sensor data collected using regular or FRC requests and the sensor type value is not recognized by the library.
Inherited Members
- builtins.ValueError
- ValueError
- builtins.BaseException
- with_traceback
- add_note
- args
289class ResponseFactoryRegisterError(KeyError): 290 """Response factory cannot be registered. 291 292 This error is raised when a response factory is attempted to be registered under existing 293 combination of pnum and pcmd for DPA messages or existing message type for JSON API responses. 294 """
Response factory cannot be registered.
This error is raised when a response factory is attempted to be registered under existing combination of pnum and pcmd for DPA messages or existing message type for JSON API responses.
Inherited Members
- builtins.KeyError
- KeyError
- builtins.BaseException
- with_traceback
- add_note
- args