Story #105846070 - show error message to user when service not available

This commit is contained in:
Matt Farnsworth 2015-12-11 15:46:29 +02:00
parent c926aa4100
commit 352c748258
3 changed files with 8 additions and 3 deletions

View file

@ -2,6 +2,11 @@ class Registrant::DomainsController < RegistrantController
def index
authorize! :view, :registrant_domains
ident_cc, ident = @current_user.registrant_ident.split '-'
@domains = BusinessRegistryCache.fetch_associated_domains ident, ident_cc
begin
@domains = BusinessRegistryCache.fetch_associated_domains ident, ident_cc
rescue Soap::Arireg::NotAvailableError => error
flash[:notice] = I18n.t(error.message[:message])
@domains = []
end
end
end

View file

@ -48,7 +48,7 @@ class BusinessRegistryCache < ActiveRecord::Base
cache = BusinessRegistryCache.find_by(ident: ident_code, ident_country_code: ident_cc)
# fetch new data if cache is expired
return cache if cache.present? && cache.retrieved_on > (Time.zone.now - Setting.days_to_keep_business_registry_cache.days)
cache = nil # expired data is forbidden
cache = [] # expired data is forbidden
data = business_registry.associated_businesses(ident_code, ident_cc)
unless data.nil?
cache = BusinessRegistryCache.new(data)

View file

@ -16,7 +16,7 @@
%th{class: 'col-xs-2'}
= t(:registrar)
%tbody
- @domains.each do |x|
- @domains.try(:each) do |x|
%tr
%td= x
%td= x.registrant