Source code for pymodbus.exceptions

'''
Pymodbus Exceptions
--------------------

Custom exceptions to be used in the Modbus code.
'''


[docs]class ModbusException(Exception): ''' Base modbus exception '''
[docs] def __init__(self, string): ''' Initialize the exception :param string: The message to append to the error ''' self.string = string
def __str__(self): return 'Modbus Error: %s' % self.string
[docs]class ModbusIOException(ModbusException): ''' Error resulting from data i/o '''
[docs] def __init__(self, string=""): ''' Initialize the exception :param string: The message to append to the error ''' message = "[Input/Output] %s" % string ModbusException.__init__(self, message)
[docs]class ParameterException(ModbusException): ''' Error resulting from invalid parameter '''
[docs] def __init__(self, string=""): ''' Initialize the exception :param string: The message to append to the error ''' message = "[Invalid Parameter] %s" % string ModbusException.__init__(self, message)
class NoSuchSlaveException(ModbusException): ''' Error resulting from making a request to a slave that does not exist ''' def __init__(self, string=""): ''' Initialize the exception :param string: The message to append to the error ''' message = "[No Such Slave] %s" % string ModbusException.__init__(self, message)
[docs]class NotImplementedException(ModbusException): ''' Error resulting from not implemented function '''
[docs] def __init__(self, string=""): ''' Initialize the exception :param string: The message to append to the error ''' message = "[Not Implemented] %s" % string ModbusException.__init__(self, message)
class ConnectionException(ModbusException): ''' Error resulting from a bad connection ''' def __init__(self, string=""): ''' Initialize the exception :param string: The message to append to the error ''' message = "[Connection] %s" % string ModbusException.__init__(self, message) class InvalidResponseRecievedException(ModbusException): """ Error resulting from invalid response received or decoded """ def __init__(self, string=""): ''' Initialize the exception :param string: The message to append to the error ''' message = "[Invalid Response] %s" % string ModbusException.__init__(self, message) #---------------------------------------------------------------------------# # Exported symbols #---------------------------------------------------------------------------# __all__ = [ "ModbusException", "ModbusIOException", "ParameterException", "NotImplementedException", "ConnectionException", "NoSuchSlaveException", ]