Skip to content
This repository has been archived by the owner on Nov 1, 2017. It is now read-only.

Commit

Permalink
trap and warn about missing hoptoad
Browse files Browse the repository at this point in the history
  • Loading branch information
ddollar committed Mar 25, 2011
1 parent 0c038ab commit 6a41879
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/taps/server.rb
@@ -1,14 +1,9 @@
require 'hoptoad_notifier'
require 'sinatra/base'
require 'taps/config'
require 'taps/utils'
require 'taps/db_session'
require 'taps/data_stream'

HoptoadNotifier.configure do |config|
config.api_key = ENV["HOPTOAD_API_KEY"]
end

module Taps
class Server < Sinatra::Base
use Rack::Auth::Basic do |login, password|
Expand All @@ -18,8 +13,17 @@ class Server < Sinatra::Base
use Rack::Deflater unless ENV['NO_DEFLATE']

error do
HoptoadNotifier.notify(e)
e = request.env['sinatra.error']
begin
require 'hoptoad_notifier'
HoptoadNotifier.configure do |config|
config.api_key = ENV["HOPTOAD_API_KEY"]
end
HoptoadNotifier.notify(e)
rescue LoadError
puts "An error occurred but Hoptoad was not notified. To use Hoptoad, please"
puts "install the 'hoptoad_notifier' gem and set ENV[\"HOPTOAD_API_KEY\"]"
end
if e.kind_of?(Taps::BaseError)
content_type "application/json"
halt 412, { 'error_class' => e.class.to_s, 'error_message' => e.message, 'error_backtrace' => e.backtrace.join("\n") }.to_json
Expand Down

0 comments on commit 6a41879

Please sign in to comment.