mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 12:47:29 +02:00
REPP: Refactor handle_errors()
This commit is contained in:
parent
a495c2ab1c
commit
b0f9d316c9
1 changed files with 13 additions and 14 deletions
|
@ -27,26 +27,25 @@ module Repp
|
||||||
def handle_errors(obj = nil, update: false)
|
def handle_errors(obj = nil, update: false)
|
||||||
@epp_errors ||= []
|
@epp_errors ||= []
|
||||||
|
|
||||||
if obj
|
obj&.construct_epp_errors
|
||||||
obj.construct_epp_errors
|
@epp_errors += obj.errors[:epp_errors] if obj
|
||||||
@epp_errors += obj.errors[:epp_errors]
|
|
||||||
end
|
|
||||||
|
|
||||||
if update
|
|
||||||
@epp_errors.each_with_index do |errors, index|
|
|
||||||
next unless errors[:code] == '2304' && errors[:value].present? &&
|
|
||||||
errors[:value][:val] == DomainStatus::SERVER_DELETE_PROHIBITED &&
|
|
||||||
errors[:value][:obj] == 'status'
|
|
||||||
|
|
||||||
@epp_errors[index][:value][:val] = DomainStatus::PENDING_UPDATE
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
format_epp_errors if update
|
||||||
@epp_errors.uniq!
|
@epp_errors.uniq!
|
||||||
|
|
||||||
render_epp_error
|
render_epp_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_epp_errors
|
||||||
|
@epp_errors.each_with_index do |errors, index|
|
||||||
|
next unless errors[:code] == '2304' && errors[:value].present? &&
|
||||||
|
errors[:value][:val] == DomainStatus::SERVER_DELETE_PROHIBITED &&
|
||||||
|
errors[:value][:obj] == 'status'
|
||||||
|
|
||||||
|
@epp_errors[index][:value][:val] = DomainStatus::PENDING_UPDATE
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def render_epp_error
|
def render_epp_error
|
||||||
render(
|
render(
|
||||||
json: { code: @epp_errors[0][:code], message: @epp_errors[0][:msg] },
|
json: { code: @epp_errors[0][:code], message: @epp_errors[0][:msg] },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue