Sha256: afd1fac648e86e3c2227a16d82d2c876ce2020f6c8196d2b1fa243495979e664

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

require 'sinatra/base'
require 'toadhopper'

module Sinatra
  # The Toadhopper helper methods
  module Toadhopper
    # Reports the current sinatra error to Hoptoad
    def post_error_to_hoptoad!
      options.toadhopper.each_pair {|k, v| ::Toadhopper.__send__("#{k}=", v)} if options.respond_to?(:toadhopper)
      unless ::Toadhopper.api_key
        STDERR.puts "WARNING: Ignoring hoptoad notification - :api_key not set"
        return
      end
      ::Toadhopper.post!(
        env['sinatra.error'],
        {
          :environment => ENV,
          :request => {
            :params     => params,
            :rails_root => options.root,
            :url        => request.url
          },
          :session => {
            :key  => 42, # Doesn't apply to Rack sessions
            :data => session
          }
        },
        {'X-Hoptoad-Client-Name' => 'toadhopper-sinatra'}
      )
    end
  end
  helpers Toadhopper
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
toolmantim-toadhopper-sinatra-0.7 lib/sinatra/toadhopper.rb