Sha256: e237f882df9f51addcbd6fd16c0d211b331d1bda3c20f4b90eaa059255a092de

Contents?: true

Size: 1.03 KB

Versions: 21

Compression:

Stored size: 1.03 KB

Contents

module Airbrake
  # Middleware for Sinatra applications. Any errors raised by the upstream
  # application will be delivered to Airbrake and re-raised.

  # Synopsis:

  #   require 'sinatra'
  #   require 'airbrake'

  #   Airbrake.configure do |config|
  #     config.api_key = 'my api key'
  #   end

  #   use Airbrake::Sinatra

  #   get '/' do
  #     raise "Sinatra has left the building"
  #   end
  #
  # Use a standard Airbrake.configure call to configure your api key.
  class Sinatra < Rack

    def initialize(app)
      super
      Airbrake.configuration.environment_name ||= environment_name(app)
      Airbrake.configuration.framework        = "Sinatra: #{::Sinatra::VERSION}"
    end

    def framework_exception(env)
      env['sinatra.error']
    end

    def environment_name(app)
      "#{app.settings.environment}"
    rescue
      ENV["RACK_ENV"] || warn("[Airbrake] Couldn't determine environment name automatically. "\
        "Please set your environment name manually by setting 'config.environment_name='.")
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
airbrakeV4rails5-4.3.8 lib/airbrake/sinatra.rb
airbrake-4.3.8 lib/airbrake/sinatra.rb
airbrake-4.3.7 lib/airbrake/sinatra.rb
airbrake-4.3.6 lib/airbrake/sinatra.rb
airbrake-4.3.5 lib/airbrake/sinatra.rb
airbrake-4.3.4 lib/airbrake/sinatra.rb
airbrake-4.3.3 lib/airbrake/sinatra.rb
airbrake-4.3.2 lib/airbrake/sinatra.rb
airbrake-4.3.1 lib/airbrake/sinatra.rb
airbrake-4.3.0 lib/airbrake/sinatra.rb
airbrake-4.2.1 lib/airbrake/sinatra.rb
airbrake-4.2.0 lib/airbrake/sinatra.rb
airbrake-4.1.0 lib/airbrake/sinatra.rb
airbrake-4.0.0 lib/airbrake/sinatra.rb
airbrake-3.2.1 lib/airbrake/sinatra.rb
airbrake-3.2.0 lib/airbrake/sinatra.rb
airbrake-3.1.17 lib/airbrake/sinatra.rb
airbrake-3.1.16 lib/airbrake/sinatra.rb
airbrake-3.1.15 lib/airbrake/sinatra.rb
airbrake-3.1.14 lib/airbrake/sinatra.rb