Hello,
I work with Rails and use Sentry to automatically log in to my applications. When an exception is thrown the error is not generated, so I have to force capture of the error through the command:
Raven.captureMessage(e.message, level: 'error')
But I would not want that in almost every exception to have to repeat that line.
I tried to create a class to avoid repetition, but I did not succeed, it follows my attempt (file created in lib / raven_error.rb):
class RavenError < StandardError
def initialize exception
super
Raven.captureMessage(exception.message, level: 'error')
end
end
Controller example:
def create
@user = User.new(user_params)
begin
@user.save
rescue RavenError => e
render :new
end
I would like the captureMessage method to be executed by instantiating the RavenError exception, without having to be inquiring into every rescue I have.