Sha256: df51ba009bb8020c88a65c93c0c8f5a73c81e7e23b3fadffb11162e8d051f18e

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 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
toadhopper-sinatra-0.7 lib/sinatra/toadhopper.rb