Skip to content

Commit

Permalink
added details to error message
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Nov 25, 2024
1 parent 1dd0d29 commit cded813
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions app/models/contact/company_register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cded813

Please sign in to comment.