Value returning with error message

This commit is contained in:
Martin Lensment 2014-08-01 15:39:20 +03:00
parent 3fc3bfc1c4
commit e4ac417bde
5 changed files with 28 additions and 3 deletions

View file

@ -35,7 +35,19 @@ module Epp::Common
def handle_errors(error_code_map, obj)
obj.errors.each do |key, err|
error_code_map.each do |code, values|
epp_errors << {code: code, msg: err} and break if values.any? {|x| obj.errors.added?(key, x) }
if err.is_a?(Hash)
epp_errors << {
code: code,
msg: err[:msg],
value: {obj: err[:obj], val: err[:val]},
} and break if values.any? {|x| I18n.t("errors.messages.#{x}") == err[:msg] }
else
epp_errors << {
code: code,
msg: err,
} and break if values.any? {|x| obj.errors.added?(key, x) }
end
end
end
end

View file

@ -33,7 +33,13 @@ class Domain < ActiveRecord::Base
v.each do |x|
contact = Contact.find_by(code: x[:contact])
attach_contact(k, contact) and next if contact
errors.add(:domain_contacts, I18n.t('errors.messages.epp_contact_not_found'))
# Detailed error message with value to display in EPP response
errors.add(:domain_contacts, {
obj: 'contact',
val: x[:contact],
msg: I18n.t('errors.messages.epp_contact_not_found')
})
end
end

View file

@ -4,6 +4,10 @@ xml.epp_head do
xml.result('code' => x[:code]) do
xml.msg(x[:msg], 'lang' => 'en')
xml.value('xmlns:obj' => 'urn:ietf:params:xml:ns:obj') do
xml.tag!("obj:#{x[:value][:obj]}", x[:value][:val])
end if x[:value]
x[:ext_values].each do |y|
xml.extValue do
xml.value do