[niepce] * src/fwk/utils/fractions.cpp (fwk): Catch conversion exceptions.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [niepce] * src/fwk/utils/fractions.cpp (fwk): Catch conversion exceptions.
- Date: Fri, 24 Apr 2009 16:31:13 -0400 (EDT)
commit 19986c0fc523a7c45869c0933da1a955c62ffa3a
Author: Hubert Figuiere <hub figuiere net>
Date: Fri Apr 24 16:30:08 2009 -0400
* src/fwk/utils/fractions.cpp (fwk): Catch conversion exceptions.
---
ChangeLog | 4 ++++
src/fwk/utils/fractions.cpp | 13 +++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7b78828..b1e403c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-04-24 Hubert Figuiere <hub figuiere net>
+
+ * src/fwk/utils/fractions.cpp (fwk): Catch conversion exceptions.
+
2009-04-21 Hubert Figuiere <hub figuiere net>
* src/engine/db/filebundle.cpp: path::stem() is not
diff --git a/src/fwk/utils/fractions.cpp b/src/fwk/utils/fractions.cpp
index 765f3e4..02c06f7 100644
--- a/src/fwk/utils/fractions.cpp
+++ b/src/fwk/utils/fractions.cpp
@@ -21,6 +21,7 @@
#include <boost/rational.hpp>
#include <boost/lexical_cast.hpp>
+#include "debug.h"
#include "fractions.hpp"
namespace fwk {
@@ -28,8 +29,16 @@ namespace fwk {
double fraction_to_decimal(const std::string & value)
{
- boost::rational<int> r = boost::lexical_cast<boost::rational<int> >(value);
- return boost::rational_cast<double>(r);
+ double v = 0.0;
+
+ try {
+ boost::rational<int> r = boost::lexical_cast<boost::rational<int> >(value);
+ v = boost::rational_cast<double>(r);
+ }
+ catch(const std::exception & e) {
+ ERR_OUT("unable to cast fraction '%s': %s", value.c_str(), e.what());
+ }
+ return v;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]