mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
Merge pull request #1713 from internetee/1708-business-registry-endpoint
Change error handling to more humane
This commit is contained in:
commit
db68a3d95a
2 changed files with 26 additions and 4 deletions
|
@ -16,9 +16,9 @@ module Api
|
|||
end
|
||||
|
||||
def current_user_companies
|
||||
current_registrant_user.companies
|
||||
[:ok, current_registrant_user.companies]
|
||||
rescue CompanyRegister::NotAvailableError
|
||||
[]
|
||||
[:service_unavailable, []]
|
||||
end
|
||||
|
||||
def limit
|
||||
|
@ -35,8 +35,8 @@ module Api
|
|||
end
|
||||
|
||||
def companies_result(limit, offset)
|
||||
@companies = current_user_companies.drop(offset).first(limit)
|
||||
status = @companies.present? ? :ok : :not_found
|
||||
status, all_companies = current_user_companies
|
||||
@companies = all_companies.drop(offset).first(limit)
|
||||
|
||||
serialized_companies = @companies.map do |item|
|
||||
country_code = current_registrant_user.country.alpha3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue