Add Airbrake support

This commit is contained in:
2012-03-06 15:51:59 +01:00
parent 9d124ce48a
commit c1d9ac39ba
4 changed files with 30 additions and 1 deletions
+21 -1
View File
@@ -11,12 +11,13 @@ class LiquorCabinet < Sinatra::Base
def self.config=(config)
@config = config
configure_airbrake
end
def self.config
return @config if @config
config = File.read(File.expand_path('config.yml', File.dirname(__FILE__)))
@config = YAML.load(config)[ENV['RACK_ENV']]
self.config = YAML.load(config)[ENV['RACK_ENV']]
end
configure :development do
@@ -44,6 +45,10 @@ class LiquorCabinet < Sinatra::Base
"Ohai."
end
get "/airbrake" do
raise "Ohai, exception from Sinatra app"
end
get "/:user/:category/:key" do
get_data(@user, @category, @key)
end
@@ -61,4 +66,19 @@ class LiquorCabinet < Sinatra::Base
halt 200
end
private
def self.configure_airbrake
if @config['airbrake'] && @config['airbrake']['api_key']
require "airbrake"
Airbrake.configure do |airbrake|
airbrake.api_key = @config['airbrake']['api_key']
end
use Airbrake::Rack
enable :raise_errors
end
end
end