From 1d3fc071772dc87d3d6e8be057c48f822609f270 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Mon, 23 May 2016 14:49:21 -0700 Subject: [PATCH] Remove throw from noexcept TimeZoneProvider::get(). --- src/libqof/qof/gnc-timezone.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/libqof/qof/gnc-timezone.cpp b/src/libqof/qof/gnc-timezone.cpp index 5e726129a8..a03ecb0d33 100644 --- a/src/libqof/qof/gnc-timezone.cpp +++ b/src/libqof/qof/gnc-timezone.cpp @@ -31,6 +31,11 @@ //We'd prefer to use std::codecvt, but it's not supported by gcc until 5.0. #include #endif +extern "C" +{ +#include +static const QofLogModule log_module = "gnc-timezone"; +} using namespace gnc::date; @@ -657,7 +662,13 @@ TimeZoneProvider::get(int year) const noexcept auto iter = find_if(zone_vector.begin(), zone_vector.end(), [=](TZ_Entry e) { return e.first >= year; }); if (iter == zone_vector.end()) - throw std::out_of_range ("Year " + to_string(year) + - " isn't covered by this time zone."); + { + /* This shouldn't happen, but if it does: */ + PERR("TimeZoneProvider::get was unable to get a timezone for year %d", + year); + if (!zone_vector.empty()) + return zone_vector.back().second; + return TZ_Ptr(new boost::local_time::posix_time_zone("UTC0")); + } return iter->second; }