Skip to content

Commit

Permalink
handle all IndexErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorerlingsson committed Jun 19, 2024
1 parent 8882bdd commit f73243e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/lavinmq/queue/message_store.cr
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,10 @@ module LavinMQ
notify_empty(true) if @size.zero?
return Envelope.new(sp, msg, redelivered: false)
rescue ex : IndexError
if @rfile.pos > (@rfile.size - BytesMessage::MIN_BYTESIZE)
Log.warn { "Msg file size does not match expected value, but it does not have enough room for more messages." }
select_next_read_segment && next
return if @size.zero?
raise IO::EOFError.new("EOF but @size=#{@size}")
else
raise Error.new(@rfile, cause: ex)
end
Log.warn { "Msg file size does not match expected value, moving on to next segment" }
select_next_read_segment && next
return if @size.zero?
raise Error.new(@rfile, cause: ex)
rescue ex
raise Error.new(@rfile, cause: ex)
end
Expand Down

0 comments on commit f73243e

Please sign in to comment.