Skip to content

Commit

Permalink
Extract parse error logging into template method
Browse files Browse the repository at this point in the history
This will allow anyone using this library to customize the behavior if
they desire.
  • Loading branch information
Nate Pinsky authored and bakkdoor committed Dec 22, 2020
1 parent 6553e20 commit b0f00f4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/firehose/rack/consumer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ def self.post_subscriptions(request)
end

subs
rescue JSON::ParserError
Firehose.logger.warn "Consumer.post_subscriptions: JSON::ParserError for request body: #{body.inspect}"
rescue JSON::ParserError => e
handle_parse_error(request, body, e)
[]
end

def self.handle_parse_error(request, body, error)
Firehose.logger.warn "JSON::ParserError for request body: #{body.inspect}"
end

# Let the client configure the consumer on initialization.
def initialize
yield self if block_given?
Expand Down

0 comments on commit b0f00f4

Please sign in to comment.