Land #10862, fix issue with session reporting when DB is disabled
commit
bd7c867485
|
@ -150,12 +150,28 @@ class DataProxy
|
|||
return @current_data_service
|
||||
end
|
||||
|
||||
# Performs a set of data service operations declared within the block.
|
||||
# This passes the @current_data_service as a parameter to the block.
|
||||
# If there is no current data service registered or the data service
|
||||
# is not active, the block is not executed and the method simply returns.
|
||||
def data_service_operation(&block)
|
||||
return unless block_given?
|
||||
|
||||
begin
|
||||
data_service = self.get_data_service
|
||||
rescue
|
||||
return
|
||||
end
|
||||
|
||||
block.call(data_service) if !data_service.nil? && self.active
|
||||
end
|
||||
|
||||
def log_error(exception, ui_message)
|
||||
elog "#{ui_message}: #{exception.message}"
|
||||
exception.backtrace.each { |line| elog "#{line}" }
|
||||
# TODO: We should try to surface the original exception, instead of just a generic one.
|
||||
# This should not display the full backtrace, only the message.
|
||||
raise Exception, "#{ui_message}: #{exception.message}. See log for more details."
|
||||
raise "#{ui_message}: #{exception.message}. See log for more details."
|
||||
end
|
||||
|
||||
# Adds a valid workspace value to the opts hash before sending on to the data layer.
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
module SessionDataProxy
|
||||
def sessions(opts={})
|
||||
begin
|
||||
data_service = self.get_data_service
|
||||
add_opts_workspace(opts)
|
||||
data_service.sessions(opts)
|
||||
self.data_service_operation do |data_service|
|
||||
add_opts_workspace(opts)
|
||||
data_service.sessions(opts)
|
||||
end
|
||||
rescue => e
|
||||
self.log_error(e, "Problem retrieving sessions")
|
||||
end
|
||||
|
@ -11,9 +12,10 @@ module SessionDataProxy
|
|||
|
||||
def report_session(opts)
|
||||
begin
|
||||
data_service = self.get_data_service
|
||||
add_opts_workspace(opts)
|
||||
data_service.report_session(opts)
|
||||
self.data_service_operation do |data_service|
|
||||
add_opts_workspace(opts)
|
||||
data_service.report_session(opts)
|
||||
end
|
||||
rescue => e
|
||||
self.log_error(e, "Problem reporting session")
|
||||
end
|
||||
|
|
|
@ -2,8 +2,9 @@ module SessionEventDataProxy
|
|||
|
||||
def report_session_event(opts)
|
||||
begin
|
||||
data_service = self.get_data_service()
|
||||
data_service.report_session_event(opts)
|
||||
self.data_service_operation do |data_service|
|
||||
data_service.report_session_event(opts)
|
||||
end
|
||||
rescue => e
|
||||
self.log_error(e, "Problem reporting session event")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue