gnucash master: Remove throw from noexcept TimeZoneProvider::get().
John Ralls
jralls at code.gnucash.org
Mon May 23 17:49:30 EDT 2016
Updated via https://github.com/Gnucash/gnucash/commit/1d3fc071 (commit)
from https://github.com/Gnucash/gnucash/commit/8b04fab2 (commit)
commit 1d3fc071772dc87d3d6e8be057c48f822609f270
Author: John Ralls <jralls at ceridwen.us>
Date: Mon May 23 14:49:21 2016 -0700
Remove throw from noexcept TimeZoneProvider::get().
diff --git a/src/libqof/qof/gnc-timezone.cpp b/src/libqof/qof/gnc-timezone.cpp
index 5e72612..a03ecb0 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 <boost/locale/encoding_utf.hpp>
#endif
+extern "C"
+{
+#include <qoflog.h>
+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;
}
Summary of changes:
src/libqof/qof/gnc-timezone.cpp | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
More information about the gnucash-changes
mailing list