Method: Modbus.find_exception

Defined in:
lib/modbus/exceptions.rb

.find_exception(code) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/modbus/exceptions.rb', line 90

def self.find_exception(code)
  exceptions = [
    IllegalFunction,
    IllegalDataAddress,
    IllegalDataValue,
    ServerDeviceFailure,
    Acknowledge,
    ServerDeviceBusy,
    MemoryParityError,
    GatewayPathUnavailable,
    GatewayTargetDeviceFailedToRespond
  ]

  exceptions.find { |e| e::CODE == code } || RuntimeError
end