lib/ears/middlewares/json.rb in ears-0.8.0 vs lib/ears/middlewares/json.rb in ears-0.8.1

- old
+ new

@@ -13,13 +13,17 @@ @on_error = opts.fetch(:on_error) @symbolize_keys = opts.fetch(:symbolize_keys, true) end def call(delivery_info, metadata, payload, app) - parsed_payload = MultiJson.load(payload, symbolize_keys: symbolize_keys) + begin + parsed_payload = + MultiJson.load(payload, symbolize_keys: symbolize_keys) + rescue => e + return on_error.call(e) + end + app.call(delivery_info, metadata, parsed_payload) - rescue => e - on_error.call(e) end private attr_reader :symbolize_keys, :on_error