Created
October 2, 2012 21:06
-
-
Save kamui/3823315 to your computer and use it in GitHub Desktop.
sentry-raven in sinatra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Helpers | |
def capture_exception(e, env) | |
if ENV['SENTRY_DSN'] | |
evt = Raven::Event.capture_rack_exception(e, env) | |
Raven.send(evt) if evt | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'helpers' | |
if ENV['SENTRY_DSN'] | |
require 'raven' | |
Raven.configure do |config| | |
config.dsn = ENV['SENTRY_DSN'] | |
config.environments = %w[staging production] | |
end | |
end | |
class App < Sinatra::Base | |
helpers Helpers | |
get '/' do | |
raise StandardError, 'testing sentry' | |
# raise exception to send to sentry | |
end | |
error do | |
capture_exception env['sinatra.error'], env | |
{ message: env['sinatra.error'].message }.to_json | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment