Refactoring: Improved logging of exceptions by using standardized way.

This commit is contained in:
Thorsten Eckel 2018-11-27 10:56:23 +01:00 committed by Martin Edenhofer
parent d7401b6a57
commit eed5fe1459
3 changed files with 7 additions and 10 deletions

View file

@ -62,7 +62,7 @@ fetch one account
rescue => e rescue => e
error = "Can't use Channel::Driver::#{adapter.to_classname}: #{e.inspect}" error = "Can't use Channel::Driver::#{adapter.to_classname}: #{e.inspect}"
logger.error error logger.error error
logger.error e.backtrace logger.error e
self.status_in = 'error' self.status_in = 'error'
self.last_log_in = error self.last_log_in = error
preferences[:last_fetch] = Time.zone.now preferences[:last_fetch] = Time.zone.now
@ -102,7 +102,7 @@ stream instance of account
rescue => e rescue => e
error = "Can't use Channel::Driver::#{adapter.to_classname}: #{e.inspect}" error = "Can't use Channel::Driver::#{adapter.to_classname}: #{e.inspect}"
logger.error error logger.error error
logger.error e.backtrace logger.error e
self.status_in = 'error' self.status_in = 'error'
self.last_log_in = error self.last_log_in = error
save! save!
@ -204,7 +204,7 @@ stream all accounts
rescue => e rescue => e
error = "Can't use stream for channel (#{channel.id}): #{e.inspect}" error = "Can't use stream for channel (#{channel.id}): #{e.inspect}"
logger.error error logger.error error
logger.error e.backtrace logger.error e
channel.status_in = 'error' channel.status_in = 'error'
channel.last_log_in = error channel.last_log_in = error
channel.save! channel.save!
@ -261,7 +261,7 @@ send via account
rescue => e rescue => e
error = "Can't use Channel::Driver::#{adapter.to_classname}: #{e.inspect}" error = "Can't use Channel::Driver::#{adapter.to_classname}: #{e.inspect}"
logger.error error logger.error error
logger.error e.backtrace logger.error e
self.status_out = 'error' self.status_out = 'error'
self.last_log_out = error self.last_log_out = error
save! save!
@ -297,7 +297,7 @@ process via account
rescue => e rescue => e
error = "Can't use Channel::Driver::#{adapter.to_classname}: #{e.inspect}" error = "Can't use Channel::Driver::#{adapter.to_classname}: #{e.inspect}"
logger.error error logger.error error
logger.error e.backtrace logger.error e
self.status_in = 'error' self.status_in = 'error'
self.last_log_in = error self.last_log_in = error
save! save!

View file

@ -61,9 +61,7 @@ class Observer::Transaction < ActiveRecord::Observer
integration = backend.new(item, params) integration = backend.new(item, params)
integration.perform integration.perform
rescue => e rescue => e
Rails.logger.error 'ERROR: ' + backend.inspect Rails.logger.error e
Rails.logger.error 'ERROR: ' + e.inspect
Rails.logger.error e.backtrace.inspect
end end
end end

View file

@ -440,8 +440,7 @@ get count of tickets and tickets which match on selector
return [ticket_count, tickets] return [ticket_count, tickets]
rescue ActiveRecord::StatementInvalid => e rescue ActiveRecord::StatementInvalid => e
Rails.logger.error e.inspect Rails.logger.error e
Rails.logger.error e.backtrace
raise ActiveRecord::Rollback raise ActiveRecord::Rollback
end end
end end