Module: Pio::OpenFlow::ErrorMessage
- Included in:
- Pio::OpenFlow10::Error, Pio::OpenFlow13::Error
- Defined in:
- lib/pio/open_flow/error_message.rb
Overview
Error message parser
Instance Method Summary collapse
-
#error_classes ⇒ Object
rubocop:enable AbcSize.
-
#read(binary) ⇒ Object
rubocop:disable AbcSize.
Instance Method Details
#error_classes ⇒ Object
rubocop:enable AbcSize
27 28 29 30 31 |
# File 'lib/pio/open_flow/error_message.rb', line 27 def error_classes OpenFlow::Message.descendants.select do |each| each.parents.include? parent.const_get(:Error) end end |
#read(binary) ⇒ Object
rubocop:disable AbcSize
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pio/open_flow/error_message.rb', line 13 def read(binary) body = OpenFlow::Header.read(binary).body error = const_get(:BodyParser).read(body) klass = error_classes.find do |each| each.name.split('::').last.underscore == error.error_type.to_s end unless klass raise 'Unknown error message '\ "(type=#{error.error_type}, code=#{error.error_code})" end klass.read binary end |