Exception: RubySMB::Error::InvalidPacket
- Inherits:
-
RubySMBError
- Object
- StandardError
- RubySMBError
- RubySMB::Error::InvalidPacket
- Defined in:
- lib/ruby_smb/error.rb
Overview
Raised when trying to parse raw binary into a Packet and the data is invalid.
Instance Attribute Summary collapse
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(args = nil) ⇒ InvalidPacket
constructor
A new instance of InvalidPacket.
Constructor Details
#initialize(args = nil) ⇒ InvalidPacket
Returns a new instance of InvalidPacket.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby_smb/error.rb', line 20 def initialize(args = nil) if args.nil? super elsif args.is_a? String super(args) elsif args.is_a? Hash expected_proto = args[:expected_proto] ? translate_protocol(args[:expected_proto]) : '???' expected_cmd = args[:expected_cmd] || '???' received_proto = args[:packet]&.packet_smb_version || '???' received_cmd = get_cmd(args[:packet]) || '???' @status_code = args[:packet]&.status_code super( "Expecting #{expected_proto} protocol "\ "with command=#{expected_cmd}"\ "#{(" (" + args[:expected_custom] + ")") if args[:expected_custom]}, "\ "got #{received_proto} protocol "\ "with command=#{received_cmd}"\ "#{(" (" + args[:received_custom] + ")") if args[:received_custom]}"\ "#{(", Status: #{@status_code}") if @status_code}" ) else raise ArgumentError, "InvalidPacket expects a String or a Hash, got a #{args.class}" end end |
Instance Attribute Details
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
19 20 21 |
# File 'lib/ruby_smb/error.rb', line 19 def status_code @status_code end |