Module: Airbrake::RakeHandler

Defined in:
lib/airbrake/rake_handler.rb

Overview

Patch Rake::Application to handle errors with Airbrake

Defined Under Namespace

Modules: Rake087Methods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/airbrake/rake_handler.rb', line 3

def self.included(klass)
  klass.class_eval do
    include Rake087Methods unless defined?(Rake::VERSION) && Rake::VERSION >= '0.9.0'
    alias_method :display_error_message_without_airbrake, :display_error_message
    alias_method :display_error_message, :display_error_message_with_airbrake
  end
end

Instance Method Details

#display_error_message_with_airbrake(exception) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/airbrake/rake_handler.rb', line 11

def display_error_message_with_airbrake(exception)
  if Airbrake.sender && Airbrake.configuration &&
      (Airbrake.configuration.rescue_rake_exceptions ||
        (Airbrake.configuration.rescue_rake_exceptions===nil && !self.tty_output?))

    Airbrake.notify_or_ignore(exception,
                              :component => 'rake',
                              :action    => reconstruct_command_line,
                              :cgi_data  => environment_info,
                              :ignore    => Airbrake.configuration.ignore_rake)
  end

  display_error_message_without_airbrake(exception)
end

#environment_infoObject



30
31
32
33
34
# File 'lib/airbrake/rake_handler.rb', line 30

def environment_info
  ENV.reject do |k|
    Airbrake.configuration.rake_environment_filters.include? k
  end
end

#reconstruct_command_lineObject



26
27
28
# File 'lib/airbrake/rake_handler.rb', line 26

def reconstruct_command_line
  ARGV.join(' ')
end