Fix sentry error capturing in submissions controller

This commit is contained in:
Felix Auringer
2021-09-14 17:01:46 +03:00
committed by Sebastian Serth
parent 30603cb7ab
commit 1bf92d8c90

View File

@ -152,12 +152,14 @@ class SubmissionsController < ApplicationController
else else
Rails.logger.info("Unknown command from client: #{event[:cmd]}") Rails.logger.info("Unknown command from client: #{event[:cmd]}")
end end
rescue JSON::ParserError rescue JSON::ParserError => e
Rails.logger.info("Data received from client is not valid json: #{data.inspect}") Rails.logger.info("Data received from client is not valid json: #{data.inspect}")
Sentry.set_extras(data: data) Sentry.set_extras(data: data)
rescue TypeError Sentry.capture_exception(e)
rescue TypeError => e
Rails.logger.info("JSON data received from client cannot be parsed as hash: #{data.inspect}") Rails.logger.info("JSON data received from client cannot be parsed as hash: #{data.inspect}")
Sentry.set_extras(data: data) Sentry.set_extras(data: data)
Sentry.capture_exception(e)
end end
end end