Sha256: 8cd0dd986ab45fb4edbfe5d735cc9e838bf004cda00500259c9f2c4522f9ff62

Contents?: true

Size: 800 Bytes

Versions: 2

Compression:

Stored size: 800 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!
      if options.respond_to?(:toadhopper)
        options.toadhopper.each_pair {|k, v| ::Toadhopper.__send__("#{k}=", v)}
      end
      unless ::Toadhopper.api_key
        STDERR.puts "WARNING: Ignoring hoptoad notification - :api_key not set"
        return
      end
      ::Toadhopper.post!(
        env['sinatra.error'],
        {
          :parameters       => params,
          :url              => request.url,
          :cgi_data         => request.env,
          :environment_vars => ENV,
          :session_data     => session.to_hash
        }
      )
    end
  end
  helpers Toadhopper
end

Version data entries

2 entries across 2 versions & 2 rubygems

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