diff options
author | Gareth Rees <gareth@mysociety.org> | 2015-04-29 16:42:26 +0100 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2015-04-29 16:42:26 +0100 |
commit | 196cce975887aca513b0fca6e90f8024aff981e5 (patch) | |
tree | b9a22d6e561f9da339d8e29dd8d17d8e7ed2bea5 /app/models | |
parent | 4b6cc7d1aa1e7d095e94aad7522385d66314879b (diff) |
Rescue from Holidays::UnknownRegionErrorhotfix/0.21.0.24
If you run an Alaveteli in a region where we can’t show holiday
suggestions the holiday import page breaks. This commit rescues from
an unavailable region so that we display a friendly error message.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/holiday_import.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/models/holiday_import.rb b/app/models/holiday_import.rb index c6019fac0..98a9b96fc 100644 --- a/app/models/holiday_import.rb +++ b/app/models/holiday_import.rb @@ -84,10 +84,14 @@ class HolidayImport end def populate_from_suggestions - holiday_info = Holidays.between(start_date, end_date, @country_code.to_sym, :observed) - holiday_info.each do |holiday_info_hash| - holidays << Holiday.new(:description => holiday_info_hash[:name], - :day => holiday_info_hash[:date]) + begin + holiday_info = Holidays.between(start_date, end_date, @country_code.to_sym, :observed) + holiday_info.each do |holiday_info_hash| + holidays << Holiday.new(:description => holiday_info_hash[:name], + :day => holiday_info_hash[:date]) + end + rescue Holidays::UnknownRegionError + [] end end end |