diff --git a/app/models/contact/company_register.rb b/app/models/contact/company_register.rb index 48f660782..3c1c2fefb 100644 --- a/app/models/contact/company_register.rb +++ b/app/models/contact/company_register.rb @@ -23,39 +23,18 @@ def return_company_status def return_company_data return unless org? - retries = 1 - begin - company_register.simple_data(registration_number: ident) - rescue CompanyRegister::NotAvailableError - Rails.logger.info "CompanyRegister::NotAvailableError occurred, attempt #{retries}" - if retries <= 3 # максимум 3 попытки - sleep 1 # ждем 1 секунду - retries += 1 - retry - else - Rails.logger.error "Failed to fetch company data after #{retries-1} retries" - [] - end - end + company_register.simple_data(registration_number: ident) + rescue CompanyRegister::NotAvailableError => e + Rails.logger.info "ERROR HAPPENED: CompanyRegister::NotAvailableError #{e.message}" + [] end def return_company_details return unless org? - retries = 1 - begin - company_register.company_details(registration_number: ident) - rescue CompanyRegister::NotAvailableError - Rails.logger.info "CompanyRegister::NotAvailableError occurred, attempt #{retries}" - if retries <= 3 # максимум 3 попытки - sleep 1 # ждем 1 секунду - retries += 1 - retry - else - Rails.logger.error "Failed to fetch company details after #{retries-1} retries" - [] - end - end + company_register.company_details(registration_number: ident) + rescue CompanyRegister::NotAvailableError + [] end def company_register