airbrake 3.1.6 → 11.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/airbrake.rb +23 -150
- data/lib/airbrake/capistrano.rb +6 -42
- data/lib/airbrake/capistrano/capistrano2.rb +40 -0
- data/lib/airbrake/capistrano/capistrano3.rb +23 -0
- data/lib/airbrake/delayed_job.rb +66 -0
- data/lib/airbrake/logger.rb +103 -0
- data/lib/airbrake/rack.rb +30 -45
- data/lib/airbrake/rack/context_filter.rb +65 -0
- data/lib/airbrake/rack/http_headers_filter.rb +44 -0
- data/lib/airbrake/rack/http_params_filter.rb +27 -0
- data/lib/airbrake/rack/instrumentable.rb +136 -0
- data/lib/airbrake/rack/middleware.rb +102 -0
- data/lib/airbrake/rack/request_body_filter.rb +33 -0
- data/lib/airbrake/rack/request_store.rb +34 -0
- data/lib/airbrake/rack/route_filter.rb +51 -0
- data/lib/airbrake/rack/session_filter.rb +25 -0
- data/lib/airbrake/rack/user.rb +74 -0
- data/lib/airbrake/rack/user_filter.rb +25 -0
- data/lib/airbrake/rails.rb +25 -31
- data/lib/airbrake/rails/action_cable.rb +35 -0
- data/lib/airbrake/rails/action_cable/notify_callback.rb +22 -0
- data/lib/airbrake/rails/action_controller.rb +40 -0
- data/lib/airbrake/rails/action_controller_notify_subscriber.rb +32 -0
- data/lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb +51 -0
- data/lib/airbrake/rails/action_controller_route_subscriber.rb +33 -0
- data/lib/airbrake/rails/active_job.rb +50 -0
- data/lib/airbrake/rails/active_record.rb +36 -0
- data/lib/airbrake/rails/active_record_subscriber.rb +46 -0
- data/lib/airbrake/rails/app.rb +78 -0
- data/lib/airbrake/rails/backtrace_cleaner.rb +23 -0
- data/lib/airbrake/rails/curb.rb +32 -0
- data/lib/airbrake/rails/event.rb +81 -0
- data/lib/airbrake/rails/excon_subscriber.rb +25 -0
- data/lib/airbrake/rails/http.rb +14 -0
- data/lib/airbrake/rails/http_client.rb +16 -0
- data/lib/airbrake/rails/net_http.rb +18 -0
- data/lib/airbrake/rails/railtie.rb +151 -0
- data/lib/airbrake/rails/typhoeus.rb +16 -0
- data/lib/airbrake/rake.rb +65 -0
- data/lib/airbrake/rake/tasks.rb +112 -0
- data/lib/airbrake/resque.rb +61 -0
- data/lib/airbrake/shoryuken.rb +54 -0
- data/lib/airbrake/sidekiq.rb +55 -0
- data/lib/airbrake/sidekiq/retryable_jobs_filter.rb +53 -0
- data/lib/airbrake/sneakers.rb +72 -0
- data/lib/airbrake/version.rb +5 -1
- data/lib/generators/airbrake_generator.rb +25 -0
- data/lib/generators/airbrake_initializer.rb.erb +80 -0
- metadata +206 -259
- data/CHANGELOG +0 -944
- data/Gemfile +0 -3
- data/Guardfile +0 -6
- data/INSTALL +0 -20
- data/MIT-LICENSE +0 -22
- data/README.md +0 -556
- data/README_FOR_HEROKU_ADDON.md +0 -94
- data/Rakefile +0 -223
- data/SUPPORTED_RAILS_VERSIONS +0 -38
- data/TESTING.md +0 -41
- data/airbrake.gemspec +0 -40
- data/bin/airbrake +0 -12
- data/features/metal.feature +0 -18
- data/features/rack.feature +0 -60
- data/features/rails.feature +0 -272
- data/features/rails_with_js_notifier.feature +0 -97
- data/features/rake.feature +0 -27
- data/features/sinatra.feature +0 -29
- data/features/step_definitions/file_steps.rb +0 -10
- data/features/step_definitions/metal_steps.rb +0 -23
- data/features/step_definitions/rack_steps.rb +0 -23
- data/features/step_definitions/rails_application_steps.rb +0 -478
- data/features/step_definitions/rake_steps.rb +0 -17
- data/features/support/airbrake_shim.rb.template +0 -16
- data/features/support/env.rb +0 -18
- data/features/support/matchers.rb +0 -35
- data/features/support/rails.rb +0 -201
- data/features/support/rake/Rakefile +0 -68
- data/features/support/terminal.rb +0 -107
- data/features/user_informer.feature +0 -63
- data/generators/airbrake/airbrake_generator.rb +0 -94
- data/generators/airbrake/lib/insert_commands.rb +0 -34
- data/generators/airbrake/lib/rake_commands.rb +0 -24
- data/generators/airbrake/templates/airbrake_tasks.rake +0 -25
- data/generators/airbrake/templates/capistrano_hook.rb +0 -6
- data/generators/airbrake/templates/initializer.rb +0 -6
- data/install.rb +0 -1
- data/lib/airbrake/backtrace.rb +0 -108
- data/lib/airbrake/cli/client.rb +0 -68
- data/lib/airbrake/cli/options.rb +0 -41
- data/lib/airbrake/cli/printer.rb +0 -30
- data/lib/airbrake/cli/project.rb +0 -17
- data/lib/airbrake/cli/project_factory.rb +0 -36
- data/lib/airbrake/cli/runner.rb +0 -48
- data/lib/airbrake/cli/validator.rb +0 -8
- data/lib/airbrake/configuration.rb +0 -311
- data/lib/airbrake/extensions/blank.rb +0 -73
- data/lib/airbrake/notice.rb +0 -390
- data/lib/airbrake/rails/action_controller_catcher.rb +0 -30
- data/lib/airbrake/rails/controller_methods.rb +0 -87
- data/lib/airbrake/rails/error_lookup.rb +0 -33
- data/lib/airbrake/rails/javascript_notifier.rb +0 -47
- data/lib/airbrake/rails/middleware/exceptions_catcher.rb +0 -33
- data/lib/airbrake/rails3_tasks.rb +0 -98
- data/lib/airbrake/railtie.rb +0 -48
- data/lib/airbrake/rake_handler.rb +0 -71
- data/lib/airbrake/sender.rb +0 -128
- data/lib/airbrake/shared_tasks.rb +0 -47
- data/lib/airbrake/tasks.rb +0 -83
- data/lib/airbrake/user_informer.rb +0 -27
- data/lib/airbrake_tasks.rb +0 -64
- data/lib/rails/generators/airbrake/airbrake_generator.rb +0 -100
- data/lib/templates/javascript_notifier.erb +0 -15
- data/lib/templates/rescue.erb +0 -91
- data/rails/init.rb +0 -1
- data/resources/README.md +0 -34
- data/resources/ca-bundle.crt +0 -3376
- data/script/integration_test.rb +0 -38
- data/test/airbrake_2_3.xsd +0 -88
- data/test/airbrake_tasks_test.rb +0 -170
- data/test/backtrace_test.rb +0 -162
- data/test/capistrano_test.rb +0 -34
- data/test/catcher_test.rb +0 -333
- data/test/configuration_test.rb +0 -233
- data/test/helper.rb +0 -263
- data/test/javascript_notifier_test.rb +0 -51
- data/test/logger_test.rb +0 -79
- data/test/notice_test.rb +0 -490
- data/test/notifier_test.rb +0 -276
- data/test/rack_test.rb +0 -58
- data/test/rails_initializer_test.rb +0 -36
- data/test/recursion_test.rb +0 -10
- data/test/sender_test.rb +0 -288
- data/test/user_informer_test.rb +0 -29
@@ -1,30 +0,0 @@
|
|
1
|
-
module Airbrake
|
2
|
-
module Rails
|
3
|
-
module ActionControllerCatcher
|
4
|
-
|
5
|
-
# Sets up an alias chain to catch exceptions when Rails does
|
6
|
-
def self.included(base) #:nodoc:
|
7
|
-
base.send(:alias_method, :rescue_action_in_public_without_airbrake, :rescue_action_in_public)
|
8
|
-
base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_airbrake)
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
# Overrides the rescue_action method in ActionController::Base, but does not inhibit
|
14
|
-
# any custom processing that is defined with Rails 2's exception helpers.
|
15
|
-
def rescue_action_in_public_with_airbrake(exception)
|
16
|
-
unless airbrake_ignore_user_agent?
|
17
|
-
error_id = Airbrake.notify_or_ignore(exception, airbrake_request_data)
|
18
|
-
request.env['airbrake.error_id'] = error_id
|
19
|
-
end
|
20
|
-
rescue_action_in_public_without_airbrake(exception)
|
21
|
-
end
|
22
|
-
|
23
|
-
def airbrake_ignore_user_agent? #:nodoc:
|
24
|
-
# Rails 1.2.6 doesn't have request.user_agent, so check for it here
|
25
|
-
user_agent = request.respond_to?(:user_agent) ? request.user_agent : request.env["HTTP_USER_AGENT"]
|
26
|
-
Airbrake.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module Airbrake
|
2
|
-
module Rails
|
3
|
-
module ControllerMethods
|
4
|
-
|
5
|
-
def airbrake_request_data
|
6
|
-
{
|
7
|
-
:parameters => airbrake_filter_if_filtering(params.to_hash),
|
8
|
-
:session_data => airbrake_filter_if_filtering(airbrake_session_data),
|
9
|
-
:controller => params[:controller],
|
10
|
-
:action => params[:action],
|
11
|
-
:url => airbrake_request_url,
|
12
|
-
:cgi_data => airbrake_filter_if_filtering(request.env),
|
13
|
-
:user => airbrake_current_user
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
# This method should be used for sending manual notifications while you are still
|
20
|
-
# inside the controller. Otherwise it works like Airbrake.notify.
|
21
|
-
def notify_airbrake(hash_or_exception)
|
22
|
-
unless airbrake_local_request?
|
23
|
-
Airbrake.notify(hash_or_exception, airbrake_request_data)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def airbrake_local_request?
|
28
|
-
if defined?(::Rails.application.config)
|
29
|
-
::Rails.application.config.consider_all_requests_local || (request.local? && (!request.env["HTTP_X_FORWARDED_FOR"]))
|
30
|
-
else
|
31
|
-
consider_all_requests_local || (local_request? && (!request.env["HTTP_X_FORWARDED_FOR"]))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def airbrake_ignore_user_agent? #:nodoc:
|
36
|
-
# Rails 1.2.6 doesn't have request.user_agent, so check for it here
|
37
|
-
user_agent = request.respond_to?(:user_agent) ? request.user_agent : request.env["HTTP_USER_AGENT"]
|
38
|
-
Airbrake.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
def airbrake_filter_if_filtering(hash)
|
43
|
-
return hash if ! hash.is_a?(Hash)
|
44
|
-
|
45
|
-
|
46
|
-
if respond_to?(:filter_parameters) # Rails 2
|
47
|
-
filter_parameters(hash)
|
48
|
-
elsif defined?(ActionDispatch::Http::ParameterFilter) # Rails 3
|
49
|
-
ActionDispatch::Http::ParameterFilter.new(::Rails.application.config.filter_parameters).filter(hash)
|
50
|
-
else
|
51
|
-
hash
|
52
|
-
end rescue hash
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
def airbrake_session_data
|
57
|
-
if session.respond_to?(:to_hash)
|
58
|
-
session.to_hash
|
59
|
-
else
|
60
|
-
session.data
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def airbrake_request_url
|
65
|
-
url = "#{request.protocol}#{request.host}"
|
66
|
-
|
67
|
-
unless [80, 443].include?(request.port)
|
68
|
-
url << ":#{request.port}"
|
69
|
-
end
|
70
|
-
|
71
|
-
url << request.fullpath
|
72
|
-
url
|
73
|
-
end
|
74
|
-
|
75
|
-
def airbrake_current_user
|
76
|
-
user = begin current_user rescue current_member end
|
77
|
-
user.attributes.select do |k, v|
|
78
|
-
Airbrake.configuration.
|
79
|
-
user_attributes.map(&:to_sym).
|
80
|
-
include? k.to_sym unless v.blank?
|
81
|
-
end.symbolize_keys
|
82
|
-
rescue NoMethodError, NameError
|
83
|
-
{}
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Airbrake
|
2
|
-
module Rails
|
3
|
-
module ErrorLookup
|
4
|
-
|
5
|
-
# Sets up an alias chain to catch exceptions when Rails does
|
6
|
-
def self.included(base) #:nodoc:
|
7
|
-
base.send(:alias_method, :rescue_action_locally_without_airbrake, :rescue_action_locally)
|
8
|
-
base.send(:alias_method, :rescue_action_locally, :rescue_action_locally_with_airbrake)
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def rescue_action_locally_with_airbrake(exception)
|
14
|
-
result = rescue_action_locally_without_airbrake(exception)
|
15
|
-
|
16
|
-
if Airbrake.configuration.development_lookup
|
17
|
-
path = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'rescue.erb')
|
18
|
-
notice = Airbrake.build_lookup_hash_for(exception, airbrake_request_data)
|
19
|
-
|
20
|
-
result << @template.render(
|
21
|
-
:file => path,
|
22
|
-
:use_full_path => false,
|
23
|
-
:locals => { :host => Airbrake.configuration.host,
|
24
|
-
:api_key => Airbrake.configuration.api_key,
|
25
|
-
:notice => notice })
|
26
|
-
end
|
27
|
-
|
28
|
-
result
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Airbrake
|
2
|
-
module Rails
|
3
|
-
module JavascriptNotifier
|
4
|
-
def self.included(base) #:nodoc:
|
5
|
-
base.send :helper_method, :airbrake_javascript_notifier
|
6
|
-
end
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def airbrake_javascript_notifier
|
11
|
-
return unless Airbrake.configuration.public?
|
12
|
-
|
13
|
-
path = File.join File.dirname(__FILE__), '..', '..', 'templates', 'javascript_notifier.erb'
|
14
|
-
host = Airbrake.configuration.host.dup
|
15
|
-
port = Airbrake.configuration.port
|
16
|
-
host << ":#{port}" unless [80, 443].include?(port)
|
17
|
-
|
18
|
-
options = {
|
19
|
-
:file => path,
|
20
|
-
:layout => false,
|
21
|
-
:use_full_path => false,
|
22
|
-
:locals => {
|
23
|
-
:host => host,
|
24
|
-
:api_key => Airbrake.configuration.js_api_key,
|
25
|
-
:environment => Airbrake.configuration.environment_name,
|
26
|
-
:action_name => action_name,
|
27
|
-
:controller_name => controller_name,
|
28
|
-
:url => request.url
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
res = if @template
|
33
|
-
@template.render(options)
|
34
|
-
else
|
35
|
-
render_to_string(options)
|
36
|
-
end
|
37
|
-
|
38
|
-
if res.respond_to?(:html_safe)
|
39
|
-
res.html_safe
|
40
|
-
else
|
41
|
-
res
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Airbrake
|
2
|
-
module Rails
|
3
|
-
module Middleware
|
4
|
-
module ExceptionsCatcher
|
5
|
-
def self.included(base)
|
6
|
-
base.send(:alias_method_chain,:render_exception,:airbrake)
|
7
|
-
end
|
8
|
-
|
9
|
-
def skip_user_agent?(env)
|
10
|
-
user_agent = env["HTTP_USER_AGENT"]
|
11
|
-
::Airbrake.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
|
12
|
-
rescue
|
13
|
-
false
|
14
|
-
end
|
15
|
-
|
16
|
-
def render_exception_with_airbrake(env,exception)
|
17
|
-
begin
|
18
|
-
controller = env['action_controller.instance']
|
19
|
-
env['airbrake.error_id'] = Airbrake.
|
20
|
-
notify_or_ignore(exception,
|
21
|
-
controller.try(:airbrake_request_data) || {:rack_env => env}) unless skip_user_agent?(env)
|
22
|
-
if defined?(controller.rescue_action_in_public_without_airbrake)
|
23
|
-
controller.rescue_action_in_public_without_airbrake(exception)
|
24
|
-
end
|
25
|
-
rescue
|
26
|
-
# do nothing
|
27
|
-
end
|
28
|
-
render_exception_without_airbrake(env,exception)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
require 'airbrake'
|
2
|
-
require File.join(File.dirname(__FILE__), 'shared_tasks')
|
3
|
-
|
4
|
-
namespace :airbrake do
|
5
|
-
desc "Verify your gem installation by sending a test exception to the airbrake service"
|
6
|
-
task :test => [:environment] do
|
7
|
-
Rails.logger = defined?(ActiveSupport::TaggedLogging) ?
|
8
|
-
ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) :
|
9
|
-
Logger.new(STDOUT)
|
10
|
-
|
11
|
-
def wait_for_threads
|
12
|
-
# if using multiple threads, we have to wait for
|
13
|
-
# them to finish
|
14
|
-
if GirlFriday.status.empty?
|
15
|
-
Thread.list.each do |thread|
|
16
|
-
thread.join unless thread == Thread.current
|
17
|
-
end
|
18
|
-
else
|
19
|
-
GirlFriday.shutdown!
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
Rails.logger.level = Logger::DEBUG
|
24
|
-
Airbrake.configure(true) do |config|
|
25
|
-
config.logger = Rails.logger
|
26
|
-
end
|
27
|
-
|
28
|
-
require './app/controllers/application_controller'
|
29
|
-
|
30
|
-
class AirbrakeTestingException < RuntimeError; end
|
31
|
-
|
32
|
-
unless Airbrake.configuration.api_key
|
33
|
-
puts "Airbrake needs an API key configured! Check the README to see how to add it."
|
34
|
-
exit
|
35
|
-
end
|
36
|
-
|
37
|
-
Airbrake.configuration.development_environments = []
|
38
|
-
|
39
|
-
puts "Configuration:"
|
40
|
-
Airbrake.configuration.to_hash.each do |key, value|
|
41
|
-
puts sprintf("%25s: %s", key.to_s, value.inspect.slice(0, 55))
|
42
|
-
end
|
43
|
-
|
44
|
-
unless defined?(ApplicationController)
|
45
|
-
puts "No ApplicationController found"
|
46
|
-
exit
|
47
|
-
end
|
48
|
-
|
49
|
-
puts 'Setting up the Controller.'
|
50
|
-
class ApplicationController
|
51
|
-
# This is to bypass any filters that may prevent access to the action.
|
52
|
-
prepend_before_filter :test_airbrake
|
53
|
-
def test_airbrake
|
54
|
-
puts "Raising '#{exception_class.name}' to simulate application failure."
|
55
|
-
raise exception_class.new, 'Testing airbrake via "rake airbrake:test". If you can see this, it works.'
|
56
|
-
end
|
57
|
-
|
58
|
-
# def rescue_action(exception)
|
59
|
-
# rescue_action_in_public exception
|
60
|
-
# end
|
61
|
-
|
62
|
-
# Ensure we actually have an action to go to.
|
63
|
-
def verify; end
|
64
|
-
|
65
|
-
# def consider_all_requests_local
|
66
|
-
# false
|
67
|
-
# end
|
68
|
-
|
69
|
-
# def local_request?
|
70
|
-
# false
|
71
|
-
# end
|
72
|
-
|
73
|
-
def exception_class
|
74
|
-
exception_name = ENV['EXCEPTION'] || "AirbrakeTestingException"
|
75
|
-
Object.const_get(exception_name)
|
76
|
-
rescue
|
77
|
-
Object.const_set(exception_name, Class.new(Exception))
|
78
|
-
end
|
79
|
-
|
80
|
-
def logger
|
81
|
-
nil
|
82
|
-
end
|
83
|
-
end
|
84
|
-
class AirbrakeVerificationController < ApplicationController; end
|
85
|
-
|
86
|
-
Rails.application.routes_reloader.execute_if_updated
|
87
|
-
Rails.application.routes.draw do
|
88
|
-
match 'verify' => 'application#verify', :as => 'verify'
|
89
|
-
end
|
90
|
-
|
91
|
-
puts 'Processing request.'
|
92
|
-
env = Rack::MockRequest.env_for("/verify")
|
93
|
-
|
94
|
-
Rails.application.call(env)
|
95
|
-
|
96
|
-
wait_for_threads
|
97
|
-
end
|
98
|
-
end
|
data/lib/airbrake/railtie.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'airbrake'
|
2
|
-
require 'rails'
|
3
|
-
|
4
|
-
module Airbrake
|
5
|
-
class Railtie < ::Rails::Railtie
|
6
|
-
rake_tasks do
|
7
|
-
require 'airbrake/rake_handler'
|
8
|
-
require "airbrake/rails3_tasks"
|
9
|
-
end
|
10
|
-
|
11
|
-
initializer "airbrake.use_rack_middleware" do |app|
|
12
|
-
app.config.middleware.insert 0, "Airbrake::UserInformer"
|
13
|
-
app.config.middleware.insert_after "Airbrake::UserInformer","Airbrake::Rack"
|
14
|
-
end
|
15
|
-
|
16
|
-
config.after_initialize do
|
17
|
-
Airbrake.configure(true) do |config|
|
18
|
-
config.logger ||= config.async? ? ::Logger.new(STDERR) : ::Rails.logger
|
19
|
-
config.environment_name ||= ::Rails.env
|
20
|
-
config.project_root ||= ::Rails.root
|
21
|
-
config.framework = "Rails: #{::Rails::VERSION::STRING}"
|
22
|
-
end
|
23
|
-
|
24
|
-
ActiveSupport.on_load(:action_controller) do
|
25
|
-
# Lazily load action_controller methods
|
26
|
-
#
|
27
|
-
require 'airbrake/rails/javascript_notifier'
|
28
|
-
require 'airbrake/rails/controller_methods'
|
29
|
-
|
30
|
-
include Airbrake::Rails::JavascriptNotifier
|
31
|
-
include Airbrake::Rails::ControllerMethods
|
32
|
-
end
|
33
|
-
|
34
|
-
if defined?(::ActionDispatch::DebugExceptions)
|
35
|
-
# We should catch the exceptions in ActionDispatch::DebugExceptions in Rails 3.2.x.
|
36
|
-
#
|
37
|
-
require 'airbrake/rails/middleware/exceptions_catcher'
|
38
|
-
::ActionDispatch::DebugExceptions.send(:include,Airbrake::Rails::Middleware::ExceptionsCatcher)
|
39
|
-
elsif defined?(::ActionDispatch::ShowExceptions)
|
40
|
-
# ActionDispatch::DebugExceptions is not defined in Rails 3.0.x and 3.1.x so
|
41
|
-
# catch the exceptions in ShowExceptions.
|
42
|
-
#
|
43
|
-
require 'airbrake/rails/middleware/exceptions_catcher'
|
44
|
-
::ActionDispatch::ShowExceptions.send(:include,Airbrake::Rails::Middleware::ExceptionsCatcher)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# Patch Rake::Application to handle errors with Airbrake
|
2
|
-
module Airbrake::RakeHandler
|
3
|
-
def self.included(klass)
|
4
|
-
klass.class_eval do
|
5
|
-
include Rake087Methods unless defined?(Rake::VERSION) && Rake::VERSION >= '0.9.0'
|
6
|
-
alias_method :display_error_message_without_airbrake, :display_error_message
|
7
|
-
alias_method :display_error_message, :display_error_message_with_airbrake
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def display_error_message_with_airbrake(ex)
|
12
|
-
if Airbrake.sender && Airbrake.configuration &&
|
13
|
-
(Airbrake.configuration.rescue_rake_exceptions ||
|
14
|
-
(Airbrake.configuration.rescue_rake_exceptions===nil && !self.tty_output?))
|
15
|
-
|
16
|
-
Airbrake.notify_or_ignore(ex, :component => reconstruct_command_line, :cgi_data => environment_info)
|
17
|
-
end
|
18
|
-
|
19
|
-
display_error_message_without_airbrake(ex)
|
20
|
-
end
|
21
|
-
|
22
|
-
def reconstruct_command_line
|
23
|
-
"rake #{ARGV.join( ' ' )}"
|
24
|
-
end
|
25
|
-
|
26
|
-
def environment_info
|
27
|
-
ENV.reject do |k|
|
28
|
-
Airbrake.configuration.rake_environment_filters.include? k
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# This module brings Rake 0.8.7 error handling to 0.9.0 standards
|
33
|
-
module Rake087Methods
|
34
|
-
# Method taken from Rake 0.9.0 source
|
35
|
-
#
|
36
|
-
# Provide standard exception handling for the given block.
|
37
|
-
def standard_exception_handling
|
38
|
-
begin
|
39
|
-
yield
|
40
|
-
rescue SystemExit => ex
|
41
|
-
# Exit silently with current status
|
42
|
-
raise
|
43
|
-
rescue OptionParser::InvalidOption => ex
|
44
|
-
$stderr.puts ex.message
|
45
|
-
exit(false)
|
46
|
-
rescue Exception => ex
|
47
|
-
# Exit with error message
|
48
|
-
display_error_message(ex)
|
49
|
-
exit(false)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# Method extracted from Rake 0.8.7 source
|
54
|
-
def display_error_message(ex)
|
55
|
-
$stderr.puts "#{name} aborted!"
|
56
|
-
$stderr.puts ex.message
|
57
|
-
if options.trace
|
58
|
-
$stderr.puts ex.backtrace.join("\n")
|
59
|
-
else
|
60
|
-
$stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
|
61
|
-
$stderr.puts "(See full trace by running task with --trace)"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
Rake.application.instance_eval do
|
68
|
-
class << self
|
69
|
-
include Airbrake::RakeHandler
|
70
|
-
end
|
71
|
-
end
|