Skip to content

Commit

Permalink
Merge pull request #167 from pmconrad/exception_format_fix
Browse files Browse the repository at this point in the history
Exception format fix
  • Loading branch information
pmconrad authored Sep 19, 2019
2 parents bae416a + 20c1688 commit b986bab
Showing 1 changed file with 49 additions and 19 deletions.
68 changes: 49 additions & 19 deletions src/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,41 @@ namespace fc
*/
string exception::to_detail_string( log_level ll )const
{
fc::stringstream ss;
ss << variant(my->_code).as_string() <<" " << my->_name << ": " <<my->_what<<"\n";
for( auto itr = my->_elog.begin(); itr != my->_elog.end(); )
{
ss << itr->get_message() <<"\n";
try
{
ss << " " << json::to_string( itr->get_data() )<<"\n";
std::stringstream ss;
try {
try {
ss << variant( my->_code ).as_string();
} catch( std::bad_alloc& ) {
throw;
} catch( ... ) {
ss << "<- exception in to_detail_string.";
}
catch( const fc::assert_exception& e )
ss << " " << my->_name << ": " << my->_what << "\n";
for( auto itr = my->_elog.begin(); itr != my->_elog.end(); )
{
ss << "ERROR: Failed to convert log data to string!\n";
try {
ss << itr->get_message() <<"\n";
try
{
ss << " " << json::to_string( itr->get_data() )<<"\n";
}
catch( const fc::assert_exception& e )
{
ss << "ERROR: Failed to convert log data to string!\n";
}
ss << " " << itr->get_context().to_string();
++itr;
} catch( std::bad_alloc& ) {
throw;
} catch( ... ) {
ss << "<- exception in to_detail_string.";
}
if( itr != my->_elog.end() ) ss<<"\n";
}
ss << " " << itr->get_context().to_string();
++itr;
if( itr != my->_elog.end() ) ss<<"\n";
} catch( std::bad_alloc& ) {
throw;
} catch( ... ) {
ss << "<- exception in to_detail_string.\n";
}
return ss.str();
}
Expand All @@ -207,12 +226,23 @@ namespace fc
*/
string exception::to_string( log_level ll )const
{
fc::stringstream ss;
ss << what() << ":";
for( auto itr = my->_elog.begin(); itr != my->_elog.end(); ++itr )
{
if( itr->get_format().size() )
ss << " " << fc::format_string( itr->get_format(), itr->get_data() );
std::stringstream ss;
try {
ss << what() << ":";
for( auto itr = my->_elog.begin(); itr != my->_elog.end(); ++itr ) {
if( itr->get_format().size() )
try {
ss << " " << fc::format_string( itr->get_format(), itr->get_data() );
} catch( std::bad_alloc& ) {
throw;
} catch( ... ) {
ss << "<- exception in to_string.\n";
}
}
} catch( std::bad_alloc& ) {
throw;
} catch( ... ) {
ss << "<- exception in to_string.\n";
}
return ss.str();
}
Expand Down

0 comments on commit b986bab

Please sign in to comment.