class Krikri::Mapping::Error
An error class for exceptions thrown during `Krikri::Mapping` processes.
Collects the full set of errors encountered when mapping a given record, along with the property names that were being processed when throwing the error.
@example collecting exceptions and reraising
err = Krikri::Mapping::Error.new(record) err.add(:title, exception) raise err
Attributes
errors[RW]
original_record[RW]
Public Class Methods
new(record)
click to toggle source
@param [Krikri::OriginalRecord] record
# File lib/krikri/mapping.rb, line 84 def initialize(record) @original_record = record @errors = {} end
Public Instance Methods
add(property, parent_error)
click to toggle source
@param [Symbol] property the name of the property for the error @param [Exception] parent_error the error to add
# File lib/krikri/mapping.rb, line 92 def add(property, parent_error) errors[property] = parent_error end
message()
click to toggle source
@return [String] a message describing the full error set
# File lib/krikri/mapping.rb, line 104 def message msg = "Error processing mapping for #{original_record.local_name}\n" errors.each do |property, error| msg << "Failed on property #{property}:\n" msg << "\t#{error.message}\n\t#{error.backtrace.join("\n\t")}" end msg end
properties()
click to toggle source
@return [Array<Symbol>] the property names that caused errors
# File lib/krikri/mapping.rb, line 98 def properties errors.keys end