lib/asir/transport/payload_io.rb in asir-1.2.5 vs lib/asir/transport/payload_io.rb in asir-1.2.6
- old
+ new
@@ -7,11 +7,13 @@
# * Header line containing the number of bytes in the payload.
# * The payload bytes.
# * Blank line.
# * Footer.
module PayloadIO
- class UnexpectedResponse < Error; end
+ class UnexpectedResponse < Error;
+ attr_accessor :expected, :received
+ end
HEADER = "# asir_payload_size: "
FOOTER = "\n# asir_payload_end"
def _write payload, stream, state
@@ -38,10 +40,13 @@
_log { "_read_line_and_expect! #{stream} #{line.inspect}" }
ok = consume && consume.match(line) ? false : true
end
unless match = regexp.match(line)
_log { "_read_line_and_expect! #{stream} #{regexp.inspect} !~ #{line.inspect}" }
- raise UnexpectedResponse, "expected #{regexp.inspect}, received #{line.inspect}"
+ exc = UnexpectedResponse.new("expected #{regexp.inspect}, received #{line.inspect}")
+ exc.expected = regexp
+ exc.received = line
+ raise exc
end
match
end
# !SLIDE pause