Renewed logic for error handling

This commit is contained in:
Martin Lensment 2014-08-04 15:10:46 +03:00
parent 86dc8321c6
commit 8dfb80c1ea
5 changed files with 13 additions and 5 deletions

View file

@ -35,6 +35,11 @@ module Epp::Common
def handle_errors(error_code_map, obj)
obj.errors.each do |key, err|
error_code_map.each do |code, values|
has_error = Proc.new do |x|
x.is_a?(Array) ? obj.errors.added?(key, x[0], x[1]) : obj.errors.added?(key, x)
end
if err.is_a?(Hash)
epp_errors << {
code: code,
@ -45,7 +50,7 @@ module Epp::Common
epp_errors << {
code: code,
msg: err,
} and break if values.any? {|x| obj.errors.added?(key, x) }
} and break if values.any? {|x| has_error.call(x)}
end
end