Browse files

Encapsulated Airbrake notifications in Rake tasks

  • Loading branch information...
1 parent 16c9e62 commit 043d59558465833bd6f310ee8e0bd77130e59866 @koraktor committed May 4, 2012
Showing with 15 additions and 9 deletions.
  1. +15 −9 lib/tasks/braumeister.rake
View
24 lib/tasks/braumeister.rake
@@ -22,6 +22,20 @@ else
end
end
+if defined?(Airbrake) && !Airbrake.configuration.api_key.nil?
+ def airbrake_rescued(&action)
+ begin
+ action.call
+ rescue
+ Airbrake.notify $!
+ end
+ end
+else
+ def airbrake_rescued(&action)
+ action.call
+ end
+end
+
namespace :braumeister do
Rails.logger = Logger.new STDOUT
@@ -50,15 +64,7 @@ namespace :braumeister do
desc 'Pulls the latest changes from one or all repositories'
task_with_tracing :update, [:repo] => :select_repos do
@repos.each do |repo|
- begin
- repo.refresh
- rescue
- if defined?(Airbrake) && !Airbrake.configuration.api_key.nil?
- Airbrake.notify $!
- else
- raise $!
- end
- end
+ airbrake_rescued { repo.refresh }
end
end

0 comments on commit 043d595

Please sign in to comment.