Skip to content
Browse files

Rescue gist import exceptions so one gist exception doesn't abort all…

… of them
  • Loading branch information...
1 parent 96e2c8a commit 239a044c699cc479c12234d7b974f120dc2c0e12 @rwdaigle committed Oct 15, 2012
Showing with 13 additions and 3 deletions.
  1. +13 −3 app/models/gist_fetcher.rb
View
16 app/models/gist_fetcher.rb
@@ -28,8 +28,13 @@ def fetch_user(user_id)
# Make sure have all gist stubs imported
def fetch_gists(gh, user)
log({ns: self, fn: __method__, measure: true}, user) do
- gh.gists.each do |gh_gist|
- Gist.import(gh_gist)
+ begin
+ gh.gists.each do |gh_gist|
+ Gist.import(gh_gist)
+ end
+ rescue Exception => e
+ Airbrake.notify(e, parameters: user.to_log)
+ log({ns: self, fn: __method__, measure: true, at: :exception, message: e.message, exception: e.class}, user)
end
end
end
@@ -38,7 +43,12 @@ def fetch_gists(gh, user)
def fetch_files(gh, user)
log({ns: self, fn: __method__, measure: true}, user) do
user.gists.pluck(:gh_id).each do |gh_gist_id|
- GistFile.import(gh.gist(gh_gist_id))
+ begin
+ GistFile.import(gh.gist(gh_gist_id))
+ rescue Exception => e
+ Airbrake.notify(e, parameters: user.to_log.merge(gh_gist_id: gh_gist_id))
+ log({ns: self, fn: __method__, measure: true, gh_gist_id: gh_gist_id, at: :exception, message: e.message, exception: e.class}, user)
+ end
end
end
end

0 comments on commit 239a044

Please sign in to comment.
Something went wrong with that request. Please try again.