Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent throw in destructor #1511

Merged
merged 2 commits into from Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/db/include/graphene/db/undo_database.hpp
Expand Up @@ -59,7 +59,7 @@ namespace graphene { namespace db {
{
mv._apply_undo = false;
}
~session(); // defined in implementation file to prevent repeated compiler warnings
~session();
void commit() { _apply_undo = false; _db.commit(); }
void undo() { if( _apply_undo ) _db.undo(); _apply_undo = false; }
void merge() { if( _apply_undo ) _db.merge(); _apply_undo = false; }
Expand Down
2 changes: 1 addition & 1 deletion libraries/db/undo_database.cpp
Expand Up @@ -38,7 +38,7 @@ undo_database::session::~session()
catch ( const fc::exception& e )
{
elog( "${e}", ("e",e.to_detail_string() ) );
throw; // maybe crash..
std::terminate();
}
if( _disable_on_exit ) _db.disable();
}
Expand Down
22 changes: 13 additions & 9 deletions tests/common/database_fixture.cpp
Expand Up @@ -208,16 +208,20 @@ database_fixture::database_fixture()
}

database_fixture::~database_fixture()
{ try {
// If we're unwinding due to an exception, don't do any more checks.
// This way, boost test's last checkpoint tells us approximately where the error was.
if( !std::uncaught_exception() )
{
verify_asset_supplies(db);
BOOST_CHECK( db.get_node_properties().skip_flags == database::skip_nothing );
{
try {
// If we're unwinding due to an exception, don't do any more checks.
// This way, boost test's last checkpoint tells us approximately where the error was.
if( !std::uncaught_exception() )
{
verify_asset_supplies(db);
BOOST_CHECK( db.get_node_properties().skip_flags == database::skip_nothing );
}
return;
} catch (fc::exception& ex) {
BOOST_FAIL( ex.to_detail_string() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admittedly CAPTURE_AND_RETHROW seems pointless if it doesn't capture anything. Perhaps LOG_AND_RETHROW instead? Or why do you BOOST_FAIL on fc::exception only is better? (Note that fc macros also catch and handle other exceptions.)

}
return;
} FC_CAPTURE_AND_RETHROW() }
}

fc::ecc::private_key database_fixture::generate_private_key(string seed)
{
Expand Down