Skip to content

Commit d27425e

Browse files
committed
Raise FFI::Error::BadAmqpData in case of unexpected frames.
1 parent bf2e031 commit d27425e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/rabbitmq/ffi/ext/frame.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ def payload
1414
end
1515

1616
def as_method_to_h(free=false)
17-
# TODO: raise correct error class with enough info for appropriate action
18-
raise "Wrong frame type for method frame of event: #{self[:frame_type]}" \
19-
unless self[:frame_type] == :method
17+
raise FFI::Error::BadAmqpData,
18+
"Wrong frame type for method frame of event: #{self[:frame_type]}" \
19+
unless self[:frame_type] == :method
2020

2121
payload.to_h(free).merge(channel: self[:channel])
2222
end
2323

2424
def as_header_to_h(free=false)
25-
# TODO: raise correct error class with enough info for appropriate action
26-
raise "Wrong frame type for header frame of multiframe event: #{self[:frame_type]}" \
27-
unless self[:frame_type] == :header
25+
raise FFI::Error::BadAmqpData,
26+
"Wrong frame type for header frame of multiframe event: #{self[:frame_type]}" \
27+
unless self[:frame_type] == :header
2828

2929
properties = self[:payload][:properties]
3030
{ header: properties.decoded.to_h(free), body_size: properties[:body_size] }
3131
end
3232

3333
def as_body_to_s(free=false)
34-
# TODO: raise correct error class with enough info for appropriate action
35-
raise "Wrong frame type for body frame of multiframe event: #{self[:frame_type]}" \
36-
unless self[:frame_type] == :body
34+
raise FFI::Error::BadAmqpData,
35+
"Wrong frame type for body frame of multiframe event: #{self[:frame_type]}" \
36+
unless self[:frame_type] == :body
3737

3838
self[:payload][:body_fragment].to_s(free)
3939
end

0 commit comments

Comments
 (0)