Class: DataAnon::Core::TableErrors

Inherits:
Object
  • Object
show all
Includes:
Utils::Logging
Defined in:
lib/core/table_errors.rb

Instance Method Summary collapse

Methods included from Utils::Logging

#logger, #logger=

Constructor Details

#initialize(table_name) ⇒ TableErrors

Returns a new instance of TableErrors.



7
8
9
10
# File 'lib/core/table_errors.rb', line 7

def initialize table_name
  @table_name = table_name
  @errors = []
end

Instance Method Details

#errorsObject



17
18
19
# File 'lib/core/table_errors.rb', line 17

def errors
  @errors
end

#log_error(record, exception) ⇒ Object



12
13
14
15
# File 'lib/core/table_errors.rb', line 12

def log_error record, exception
  @errors << { :record => record, :exception => exception}
  raise 'Reached limit of error for a table' if @errors.length > 100
end


21
22
23
24
25
26
27
28
# File 'lib/core/table_errors.rb', line 21

def print
  return if @errors.length == 0
  logger.error("Errors while processing table '#{@table_name}':")
  @errors.each do |error|
    logger.error(error[:exception])
    logger.error(error[:exception].backtrace.join("\n\t"))
  end
end