Module: Sinatra::Toadhopper::Helpers

Defined in:
lib/sinatra/toadhopper.rb

Instance Method Summary collapse

Instance Method Details

#post_error_to_airbrake!Object

Reports the current sinatra error to Hoptoad



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sinatra/toadhopper.rb', line 10

def post_error_to_airbrake!
  unless airbrake_api_key
    STDERR.puts "Airbrake api key not set, e.g. set :airbrake, :api_key => 'my api key'"
    return
  end
  toadhopper = ::Toadhopper.new(airbrake_api_key, airbrake_options)
  toadhopper.filters = airbrake_filters if airbrake_filters
  toadhopper.post!(
    env['sinatra.error'],
    {
      :url => request.url,
      :params => request.params,
      :session => session.to_hash,
      :environment => ENV.to_hash,
      :framework_env => settings.environment.to_s,
      :project_root => settings.root,
      :notifier_name => (notifier_name = "toadhopper-sinatra"),
      :notifier_version => VERSION,
      :notifier_url => 'http://github.com/toolmantim/toadhopper-sinatra'
    },
    {'X-Hoptoad-Client-Name' => notifier_name}
  )
end