Browse files

Correct our general exception handling.

  • Loading branch information...
1 parent 67e4f9e commit bd021bbd91d435e07e961e37434e50a72ac140ed @maxwell maxwell committed Mar 4, 2012
View
2 app/models/jobs/base.rb
@@ -14,7 +14,7 @@ class Base
def self.suppress_annoying_errors(&block)
begin
yield
- rescue Exception => e
+ rescue => e
Rails.logger.info("error in job: #{e.message}")
unless DUMB_ERROR_MESSAGES.include?(e.message)
raise e
View
2 app/models/jobs/receive_unencrypted_salmon.rb
@@ -12,7 +12,7 @@ def self.perform(xml)
begin
receiver = Postzord::Receiver::Public.new(xml)
receiver.perform!
- rescue Exception => e
+ rescue => e
FEDERATION_LOGGER.info(e.message)
raise e
end
View
2 app/models/o_embed_cache.rb
@@ -21,7 +21,7 @@ def self.find_or_create_by_url(url)
def fetch_and_save_oembed_data!
begin
response = OEmbed::Providers.get(self.url, {:maxwidth => 420, :maxheight => 420, :frame => 1, :iframe => 1})
- rescue Exception => e
+ rescue => e
# noop
else
self.data = response.fields
View
2 app/models/person.rb
@@ -199,7 +199,7 @@ def url
url = "#{uri.scheme}://#{uri.host}"
url += ":#{uri.port}" unless ["80", "443"].include?(uri.port.to_s)
url += "/"
- rescue Exception => e
+ rescue => e
url = @attributes['url']
end
url
View
2 app/models/services/facebook.rb
@@ -11,7 +11,7 @@ def post(post, url='')
begin
post_params = self.create_post_params(message)
Faraday.post("https://graph.facebook.com/me/feed", post_params.to_param)
- rescue Exception => e
+ rescue => e
Rails.logger.info("#{e.message} failed to post to facebook")
end
end
View
2 app/models/services/tumblr.rb
@@ -24,7 +24,7 @@ def post(post, url='')
begin
resp = access.post('http://tumblr.com/api/write', body)
resp
- rescue Exception
+ rescue => e
nil
end
end
View
2 app/models/services/twitter.rb
@@ -16,7 +16,7 @@ def post(post, url='')
begin
Twitter.update(message)
- rescue Exception => e
+ rescue => e
Rails.logger.info e.message
end
end
View
2 lib/postzord/receiver/private.rb
@@ -26,7 +26,7 @@ def receive!
FEDERATION_LOGGER.info("event=receive status=abort recipient=#{@user.diaspora_handle} sender=#{@salmon.author_id} reason='not_verified for key'")
false
end
- rescue Exception => e
+ rescue => e
#this sucks
FEDERATION_LOGGER.info("Failure to receive #{@object.inspect} for sender:#{@sender.id} for user:#{@user.id}: #{e.message}")
raise e
View
2 lib/share_visibility_converter.rb
@@ -44,7 +44,7 @@ def self.copy_hidden_share_visibilities_to_users(only_recent = false)
u.hidden_shareables[type] ||= []
u.hidden_shareables[type] << id unless u.hidden_shareables[type].include?(id)
u.save!(:validate => false)
- rescue Exception =>e
+ rescue => e
puts "ERROR: #{e.message} skipping pv with id: #{visibility.id}"
end
end
View
2 lib/tasks/migrations.rake
@@ -57,7 +57,7 @@ namespace :migrations do
key.public_link();
puts "Uploaded #{current} of #{count}"
current += 1
- rescue Exception => e
+ rescue => e
puts "error #{e} on #{current} (#{file_name}), retrying"
retry
end
View
4 lib/webfinger.rb
@@ -30,7 +30,7 @@ def get(url)
Rails.logger.info("Getting: #{url} for #{account}")
begin
Faraday.get(url).body
- rescue Exception => e
+ rescue => e
Rails.logger.info("Failed to fetch: #{url} for #{account}; #{e.message}")
raise e
end
@@ -59,7 +59,7 @@ def create_or_update_person_from_webfinger_profile!
def host_meta_xrd
begin
get(host_meta_url)
- rescue Exception => e
+ rescue => e
if self.ssl
self.ssl = false
retry
View
2 lib/webfinger_profile.rb
@@ -40,7 +40,7 @@ def set_fields
begin
pubkey = text_of_attribute( doc.at('Link[rel=diaspora-public-key]'), 'href')
@public_key = Base64.decode64 pubkey
- rescue Exception => e
+ rescue => e
Rails.logger.info("event => :invalid_profile, :identifier => #{@account}")
end
end
View
2 spec/lib/webfinger_spec.rb
@@ -130,7 +130,7 @@
end
it 'should retry with ssl off a second time' do
- finger.should_receive(:get).and_raise
+ finger.should_receive(:get).and_raise(StandardError)
finger.should_receive(:get)
finger.host_meta_xrd
finger.ssl.should be false
View
2 spec/models/services/tumblr_spec.rb
@@ -16,7 +16,7 @@
end
it 'swallows exception raised by tumblr not being webscale' do
- OAuth::AccessToken.any_instance.should_receive(:post).and_raise
+ OAuth::AccessToken.any_instance.should_receive(:post).and_raise(StandardError)
@service.post(@post)
end
end
View
2 spec/models/services/twitter_spec.rb
@@ -16,7 +16,7 @@
end
it 'swallows exception raised by twitter always being down' do
- Twitter.should_receive(:update).and_raise
+ Twitter.should_receive(:update).and_raise(StandardError)
@service.post(@post)
end

0 comments on commit bd021bb

Please sign in to comment.