travis-api/lib/travis/api/app/error_handling.rb
carlad 8f6083117c add async method to send exception error to sentry
add ErrorHandling class, refactor spec

correct the raven config class

correct the raven test

add a fake method for getting an exception

require error_handling

add new TestError class to test exceptions

add correct error class to test

add rescue block to raven send

make method a class method and add a test Travis.config.dns

add error the repos to test error

remove carla method in repos

add a fake error in repos

delete carla method
2015-02-13 16:16:45 +01:00

27 lines
559 B
Ruby

require 'travis/api/app'
class Travis::Api::App
class ErrorHandling
def self.setup
return unless Travis.config.sentry.dsn
queue = ::SizedQueue.new(100)
Thread.new do
loop do
begin
Raven.send queue.pop
rescue Exception => e
puts e.message, e.backtrace
end
end
end
Raven.configure do |config|
config.async = lambda { |event| queue << event if queue.num_waiting < 100 }
config.dsn = Travis.config.sentry.dsn
end
end
end
end