Skip to content

Commit

Permalink
Converting release_assert to exception if the ledger file cannot be o…
Browse files Browse the repository at this point in the history
…pened.
  • Loading branch information
clemahieu committed Oct 16, 2023
1 parent 3b22533 commit e0c5c95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 9 additions & 2 deletions nano/core_test/block_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,15 @@ TEST (mdb_block_store, bad_path)
GTEST_SKIP ();
}
nano::logger_mt logger;
nano::store::lmdb::component store (logger, boost::filesystem::path ("///"), nano::dev::constants);
ASSERT_TRUE (store.init_error ());
try
{
nano::store::lmdb::component store (logger, boost::filesystem::path ("///"), nano::dev::constants);
}
catch (std::runtime_error &)
{
return;
}
ASSERT_TRUE (false);
}

TEST (block_store, DISABLED_already_open) // File can be shared
Expand Down
9 changes: 2 additions & 7 deletions nano/store/lmdb/lmdb_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,8 @@ void nano::store::lmdb::env::init (bool & error_a, boost::filesystem::path const
auto status4 (mdb_env_open (environment, path_a.string ().c_str (), environment_flags, 00600));
if (status4 != 0)
{
std::cerr << "Could not open lmdb environment: " << status4;
char * error_str (mdb_strerror (status4));
if (error_str)
{
std::cerr << ", " << error_str;
}
std::cerr << std::endl;
std::string message = "Could not open lmdb environment(" + std::to_string (status4) + "): " + mdb_strerror (status4);
throw std::runtime_error (message);
}
release_assert (status4 == 0);
error_a = status4 != 0;
Expand Down

0 comments on commit e0c5c95

Please sign in to comment.