Class: Renalware::UKRDC::TransmissionLog

Inherits:
ApplicationRecord show all
Defined in:
app/models/renalware/ukrdc/transmission_log.rb

Class Method Summary collapse

Class Method Details

.formatted_exception(error) ⇒ Object



37
38
39
40
41
42
# File 'app/models/renalware/ukrdc/transmission_log.rb', line 37

def self.formatted_exception(error)
  [
    "#{error.backtrace.first}: #{error.message} (#{error.class})",
    error.backtrace.drop(1).map { |line| "\t#{line}" }
  ].join("\n")
end

.with_logging(patient: nil, batch: nil, **options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/renalware/ukrdc/transmission_log.rb', line 22

def self.with_logging(patient: nil, batch: nil, **options)
  log = new(
    patient: patient,
    sent_at: Time.zone.now,
    batch: batch,
    **options)
  yield log if block_given?
  log.save!
rescue StandardError => e
  log.error << formatted_exception(e)
  log.status = :error
  log.save!
  raise e
end