class Rake::Task
Redefine +Rake::Task#execute+, so it can report errors to Airbrake
.
Public Instance Methods
execute(args = nil)
click to toggle source
A wrapper around the original #execute
, that catches all errors and notifies Airbrake
.
rubocop:disable Lint/RescueException
# File lib/airbrake/rake.rb, line 16 def execute(args = nil) execute_without_airbrake(args) rescue Exception => ex notify_airbrake(ex, args) raise ex end
Also aliased as: execute_without_airbrake
Private Instance Methods
notify_airbrake(exception, args)
click to toggle source
rubocop:enable Lint/RescueException
# File lib/airbrake/rake.rb, line 26 def notify_airbrake(exception, args) notice = Airbrake.build_notice(exception) notice[:context][:component] = 'rake' notice[:context][:action] = name notice[:params].merge!( rake_task: task_info, execute_args: args, argv: ARGV.join(' ') ) Airbrake.notify_sync(notice) end
task_info()
click to toggle source
rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
# File lib/airbrake/rake.rb, line 40 def task_info info = {} info[:name] = name info[:timestamp] = timestamp.to_s info[:investigation] = investigation info[:full_comment] = full_comment if full_comment info[:arg_names] = arg_names if arg_names.any? info[:arg_description] = arg_description if arg_description info[:locations] = locations if locations.any? info[:sources] = sources if sources.any? if prerequisite_tasks.any? info[:prerequisite_tasks] = prerequisite_tasks.map do |p| p.__send__(:task_info) end end info end