lib/eco/api/common/people/person_entry.rb in eco-helpers-1.5.13 vs lib/eco/api/common/people/person_entry.rb in eco-helpers-1.5.14

- old
+ new

@@ -168,18 +168,29 @@ end.join(" | ") end end # Setter to fill in all the `core` properties of the `Person` that are present in the `Entry`. - # @note it only sets those core properties defined in the entry. - # Meaning that if an core property is not present in the entry, this will not be set on the target person. + # @note + # 1. it only sets those core properties defined in the entry. + # Meaning that if an core property is not present in the entry, this will not be set on the target person. + # 2. if there's an incorrect email exception, it blanks the email and logs a warning message # @param person [Ecoportal::API::V1::Person] the person we want to set the core values to. # @param exclude [String, Array<String>] core attributes that should not be set/changed to the person. def set_core(person, exclude: nil) scoped_attrs = @emap.core_attrs - into_a(exclude) @final_entry.slice(*scoped_attrs).each do |attr, value| - set_part(person, attr, value) + begin + set_part(person, attr, value) + rescue Exception => e + if attr == "email" + logger.error(e.to_s + " - setting blank email instead.") + set_part(person, attr, nil) + else + raise + end + end end end # Setter to fill in the `account` properties of the `Person` that are present in the `Entry`. # @note it only sets those account properties defined in the entry. @@ -458,9 +469,10 @@ obj[attr] = value else obj.send("#{attr}=", value) end rescue Exception => e + # add more info to the error raise e.append_message " -- Entry #{to_s(:identify)}" end end # @return [Hash] `value` if it was a `Hash`, and `{ attr => value}` otherwise