1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Avoid unnecessary catching of Exception instead of StandardError.

This commit is contained in:
Dylan Smith 2012-06-17 03:26:10 -04:00
parent 7381968c08
commit c9891608aa
5 changed files with 8 additions and 8 deletions

View file

@ -370,7 +370,7 @@ module ActiveRecord
records.uniq.each do |record| records.uniq.each do |record|
begin begin
record.rolledback!(rollback) record.rolledback!(rollback)
rescue Exception => e rescue => e
record.logger.error(e) if record.respond_to?(:logger) && record.logger record.logger.error(e) if record.respond_to?(:logger) && record.logger
end end
end end
@ -385,7 +385,7 @@ module ActiveRecord
records.uniq.each do |record| records.uniq.each do |record|
begin begin
record.committed! record.committed!
rescue Exception => e rescue => e
record.logger.error(e) if record.respond_to?(:logger) && record.logger record.logger.error(e) if record.respond_to?(:logger) && record.logger
end end
end end

View file

@ -286,7 +286,7 @@ module ActiveRecord
:name => name, :name => name,
:connection_id => object_id, :connection_id => object_id,
:binds => binds) { yield } :binds => binds) { yield }
rescue Exception => e rescue => e
message = "#{e.class.name}: #{e.message}: #{sql}" message = "#{e.class.name}: #{e.message}: #{sql}"
@logger.error message if @logger @logger.error message if @logger
exception = translate_exception(e, message) exception = translate_exception(e, message)

View file

@ -264,19 +264,19 @@ module ActiveRecord
def begin_db_transaction def begin_db_transaction
execute "BEGIN" execute "BEGIN"
rescue Exception rescue
# Transactions aren't supported # Transactions aren't supported
end end
def commit_db_transaction #:nodoc: def commit_db_transaction #:nodoc:
execute "COMMIT" execute "COMMIT"
rescue Exception rescue
# Transactions aren't supported # Transactions aren't supported
end end
def rollback_db_transaction #:nodoc: def rollback_db_transaction #:nodoc:
execute "ROLLBACK" execute "ROLLBACK"
rescue Exception rescue
# Transactions aren't supported # Transactions aren't supported
end end

View file

@ -92,7 +92,7 @@ module ActiveSupport
method = message.split('.').first method = message.split('.').first
begin begin
send(method, ActiveSupport::Notifications::Event.new(message, *args)) send(method, ActiveSupport::Notifications::Event.new(message, *args))
rescue Exception => e rescue => e
logger.error "Could not log #{message.inspect} event. #{e.class}: #{e.message} #{e.backtrace}" logger.error "Could not log #{message.inspect} event. #{e.class}: #{e.message} #{e.backtrace}"
end end
end end

View file

@ -331,7 +331,7 @@ module ActiveSupport
def load def load
begin begin
@codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, 'rb') { |f| Marshal.load f.read } @codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, 'rb') { |f| Marshal.load f.read }
rescue Exception => e rescue => e
raise IOError.new("Couldn't load the Unicode tables for UTF8Handler (#{e.message}), ActiveSupport::Multibyte is unusable") raise IOError.new("Couldn't load the Unicode tables for UTF8Handler (#{e.message}), ActiveSupport::Multibyte is unusable")
end end