Skip to content

Instantly share code, notes, and snippets.

@toolmantim
Created March 2, 2009 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toolmantim/72626 to your computer and use it in GitHub Desktop.
Save toolmantim/72626 to your computer and use it in GitHub Desktop.
HoptoadNotifier.configure do |config|
config.environment = RAILS_ENV
config.application_root = RAILS_ROOT
end
class HoptoadNotifier::Rails
def self.notify(request)
# Do your thang
end
end
class ApplicationController < ActionController::Base
protected
def rescue_action_in_public(error)
HoptoadNotifier::Rails.notify(request, error)
render :text => "Something went boom"
end
end
HoptoadNotifier.configure do |config|
config.environment = Sinatra::Application.environment
config.application_root = Sinatra::Application.root
end
class HoptoadNotifier::Sinatra
def self.notify(request)
error = request.env['sinatra.error']
HoptoadNotifier.notify(
:error_class => error.class.name,
:error_message => "#{error.class.name}: #{error.message}",
:backtrace => error.backtrace,
:environment => request.env,
:request => { :params => request.params, :url => request.url }
)
end
end
# An extension of http://gist.github.com/72622
#
# If HoptoadNotifier was refactored so each framework had it's own glue lib it
# may look something like this:
require 'rubygems'
gem 'sinatra', '~> 0.9.0'
require 'sinatra'
gem 'thoughtbot-hoptoad_notifier', '42'
require 'hoptoad_notifier/sinatra'
HoptoadNotifier.api_key = 'YOUR_API_KEY'
get '/' do
raise "Eeep!"
end
error do
HoptoadNotifier::Sinatra.notify(request)
"Something went boom"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment