Created
March 2, 2009 05:26
-
-
Save toolmantim/72626 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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 |
This file contains hidden or 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
class ApplicationController < ActionController::Base | |
protected | |
def rescue_action_in_public(error) | |
HoptoadNotifier::Rails.notify(request, error) | |
render :text => "Something went boom" | |
end | |
end | |
This file contains hidden or 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
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 |
This file contains hidden or 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
# 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