errors should probably be logged as errors

This commit is contained in:
Aaron Patterson 2012-03-15 12:11:12 -07:00
parent 94a20d94d5
commit e6c95fe391
1 changed files with 18 additions and 19 deletions

View File

@ -284,26 +284,25 @@ module ActiveRecord
protected
def log(sql, name = "SQL", binds = [])
@instrumenter.instrument(
"sql.active_record",
:sql => sql,
:name => name,
:connection_id => object_id,
:binds => binds) { yield }
rescue Exception => e
message = "#{e.class.name}: #{e.message}: #{sql}"
@logger.debug message if @logger
exception = translate_exception(e, message)
exception.set_backtrace e.backtrace
raise exception
end
def translate_exception(e, message)
# override in derived class
ActiveRecord::StatementInvalid.new(message)
end
def log(sql, name = "SQL", binds = [])
@instrumenter.instrument(
"sql.active_record",
:sql => sql,
:name => name,
:connection_id => object_id,
:binds => binds) { yield }
rescue Exception => e
message = "#{e.class.name}: #{e.message}: #{sql}"
@logger.error message if @logger
exception = translate_exception(e, message)
exception.set_backtrace e.backtrace
raise exception
end
def translate_exception(e, message)
# override in derived class
ActiveRecord::StatementInvalid.new(message)
end
end
end
end