Correct our general exception handling.

thanks @mperham! see: http://t.co/Jyt7vV4I
This commit is contained in:
Maxwell Salzberg 2012-03-03 16:25:48 -08:00
parent 67e4f9e159
commit bd021bbd91
15 changed files with 16 additions and 16 deletions

View file

@ -14,7 +14,7 @@ module Jobs
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 file

@ -12,7 +12,7 @@ module Jobs
begin
receiver = Postzord::Receiver::Public.new(xml)
receiver.perform!
rescue Exception => e
rescue => e
FEDERATION_LOGGER.info(e.message)
raise e
end

View file

@ -21,7 +21,7 @@ class OEmbedCache < ActiveRecord::Base
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 file

@ -199,7 +199,7 @@ class Person < ActiveRecord::Base
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 file

@ -11,7 +11,7 @@ class Services::Facebook < Service
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 file

@ -24,7 +24,7 @@ class Services::Tumblr < Service
begin
resp = access.post('http://tumblr.com/api/write', body)
resp
rescue Exception
rescue => e
nil
end
end

View file

@ -16,7 +16,7 @@ class Services::Twitter < Service
begin
Twitter.update(message)
rescue Exception => e
rescue => e
Rails.logger.info e.message
end
end

View file

@ -26,7 +26,7 @@ class Postzord::Receiver::Private < Postzord::Receiver
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 file

@ -44,7 +44,7 @@ class ShareVisibilityConverter
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 file

@ -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 file

@ -30,7 +30,7 @@ class Webfinger
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 @@ class Webfinger
def host_meta_xrd
begin
get(host_meta_url)
rescue Exception => e
rescue => e
if self.ssl
self.ssl = false
retry

View file

@ -40,7 +40,7 @@ class WebfingerProfile
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 file

@ -130,7 +130,7 @@ describe Webfinger do
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 file

@ -16,7 +16,7 @@ describe Services::Tumblr do
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 file

@ -16,7 +16,7 @@ describe Services::Twitter do
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