From dd32afd0c3e62d1a8c70ea6effba7757af3f3743 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Thu, 5 Jun 2014 11:31:42 -0400 Subject: [PATCH] adding better exception handling on lexical casts --- src/string.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/string.cpp b/src/string.cpp index 0c49a95..2d37388 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -86,19 +87,19 @@ namespace fc { int64_t to_int64( const fc::string& i ) - { + { try { return boost::lexical_cast(i.c_str()); - } + } FC_RETHROW_EXCEPTIONS( warn, "${i} => int64_t", ("i",i) ) } uint64_t to_uint64( const fc::string& i ) - { + { try { return boost::lexical_cast(i.c_str()); - } + } FC_RETHROW_EXCEPTIONS( warn, "${i} => uint64_t", ("i",i) ) } double to_double( const fc::string& i) - { + { try { return boost::lexical_cast(i.c_str()); - } + } FC_RETHROW_EXCEPTIONS( warn, "${i} => double", ("i",i) ) } fc::string to_string( double d) {