mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
errors should probably be logged as errors
This commit is contained in:
parent
94a20d94d5
commit
e6c95fe391
1 changed files with 18 additions and 19 deletions
|
@ -284,26 +284,25 @@ module ActiveRecord
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def log(sql, name = "SQL", binds = [])
|
def log(sql, name = "SQL", binds = [])
|
||||||
@instrumenter.instrument(
|
@instrumenter.instrument(
|
||||||
"sql.active_record",
|
"sql.active_record",
|
||||||
:sql => sql,
|
:sql => sql,
|
||||||
:name => name,
|
:name => name,
|
||||||
:connection_id => object_id,
|
:connection_id => object_id,
|
||||||
:binds => binds) { yield }
|
:binds => binds) { yield }
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
message = "#{e.class.name}: #{e.message}: #{sql}"
|
message = "#{e.class.name}: #{e.message}: #{sql}"
|
||||||
@logger.debug message if @logger
|
@logger.error message if @logger
|
||||||
exception = translate_exception(e, message)
|
exception = translate_exception(e, message)
|
||||||
exception.set_backtrace e.backtrace
|
exception.set_backtrace e.backtrace
|
||||||
raise exception
|
raise exception
|
||||||
end
|
end
|
||||||
|
|
||||||
def translate_exception(e, message)
|
|
||||||
# override in derived class
|
|
||||||
ActiveRecord::StatementInvalid.new(message)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def translate_exception(e, message)
|
||||||
|
# override in derived class
|
||||||
|
ActiveRecord::StatementInvalid.new(message)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue