lib/airbrake/sinatra.rb in airbrake-3.1.12 vs lib/airbrake/sinatra.rb in airbrake-3.1.13
- old
+ new
@@ -20,14 +20,21 @@
# Use a standard Airbrake.configure call to configure your api key.
class Sinatra < Rack
def initialize(app)
super
- Airbrake.configuration.environment_name = "#{app.settings.environment}"
- Airbrake.configuration.framework = "Sinatra: #{::Sinatra::VERSION}"
+ 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