Wrap boost exceptions thrown by to_int64, to_uint64, to_double
This commit is contained in:
parent
43e02caa79
commit
594ef43f76
1 changed files with 33 additions and 9 deletions
|
|
@ -89,19 +89,43 @@ namespace fc {
|
|||
|
||||
|
||||
int64_t to_int64( const fc::string& i )
|
||||
{ try {
|
||||
return boost::lexical_cast<int64_t>(i.c_str());
|
||||
} FC_RETHROW_EXCEPTIONS( warn, "${i} => int64_t", ("i",i) ) }
|
||||
{
|
||||
try
|
||||
{
|
||||
return boost::lexical_cast<int64_t>(i.c_str());
|
||||
}
|
||||
catch( const boost::bad_lexical_cast& e )
|
||||
{
|
||||
FC_THROW_EXCEPTION( parse_error_exception, "Couldn't parse int64_t" );
|
||||
}
|
||||
FC_RETHROW_EXCEPTIONS( warn, "${i} => int64_t", ("i",i) )
|
||||
}
|
||||
|
||||
uint64_t to_uint64( const fc::string& i )
|
||||
{ try {
|
||||
return boost::lexical_cast<uint64_t>(i.c_str());
|
||||
} FC_RETHROW_EXCEPTIONS( warn, "${i} => uint64_t", ("i",i) ) }
|
||||
{
|
||||
try
|
||||
{
|
||||
return boost::lexical_cast<uint64_t>(i.c_str());
|
||||
}
|
||||
catch( const boost::bad_lexical_cast& e )
|
||||
{
|
||||
FC_THROW_EXCEPTION( parse_error_exception, "Couldn't parse uint64_t" );
|
||||
}
|
||||
FC_RETHROW_EXCEPTIONS( warn, "${i} => uint64_t", ("i",i) )
|
||||
}
|
||||
|
||||
double to_double( const fc::string& i)
|
||||
{ try {
|
||||
return boost::lexical_cast<double>(i.c_str());
|
||||
} FC_RETHROW_EXCEPTIONS( warn, "${i} => double", ("i",i) ) }
|
||||
{
|
||||
try
|
||||
{
|
||||
return boost::lexical_cast<double>(i.c_str());
|
||||
}
|
||||
catch( const boost::bad_lexical_cast& e )
|
||||
{
|
||||
FC_THROW_EXCEPTION( parse_error_exception, "Couldn't parse double" );
|
||||
}
|
||||
FC_RETHROW_EXCEPTIONS( warn, "${i} => double", ("i",i) )
|
||||
}
|
||||
|
||||
fc::string to_string( double d)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue