Skip to content

Instantly share code, notes, and snippets.

@kamui
Created October 2, 2012 21:06
Show Gist options
  • Save kamui/3823315 to your computer and use it in GitHub Desktop.
Save kamui/3823315 to your computer and use it in GitHub Desktop.
sentry-raven in sinatra
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
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