Skip to content

Commit

Permalink
Merge pull request monero-project#902
Browse files Browse the repository at this point in the history
fe113aa Kovri: don't dispatch error_with_option_name (anonimal)
  • Loading branch information
anonimal committed Jun 14, 2018
2 parents 89c0332 + fe113aa commit 9695069
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/app/daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ bool DaemonSingleton::Configure(const std::vector<std::string>& args)
// Create/configure client instance
m_Client = std::make_unique<client::Instance>(core);
}
// Catch harmless program_option exceptions without dispatching (and producing excessive logging)
catch (const boost::program_options::error_with_option_name& ex)
{
LOG(info) << ex.what() << "\nSee configuration file for details";
return false;
}
catch (...)
{
m_Exception.Dispatch(__func__);
Expand Down
4 changes: 4 additions & 0 deletions src/core/instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ Instance::Instance(const std::vector<std::string>& args) try : m_Config(args)
// Continue with configuration/setup
m_Config.SetupAESNI();
}
catch (const boost::program_options::error_with_option_name& ex)
{
// Avoids dispatcher logging without an intrusive change to the dispatcher
}
catch (...)
{
m_Exception.Dispatch();
Expand Down
11 changes: 8 additions & 3 deletions src/core/util/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

#include <memory>
#include <stdexcept>
#include <sstream>

#include "core/router/context.h"
#include "core/router/info.h"
Expand All @@ -71,6 +72,10 @@ Configuration::Configuration(const std::vector<std::string>& args) try
{
ParseConfig();
}
catch (const boost::program_options::error_with_option_name& ex)
{
// Avoids dispatcher logging without an intrusive change to the dispatcher
}
catch (...)
{
m_Exception.Dispatch();
Expand Down Expand Up @@ -190,9 +195,9 @@ void Configuration::ParseConfig()
// Help options
if (m_Map.count("help"))
{
LOG(info) << config_options;
throw std::runtime_error(
"for more details, see user-guide or config file");
std::ostringstream message;
message << config_options;
throw boost::program_options::error_with_option_name(message.str());
}
// Parse config file after mapping command-line
// TODO(anonimal): we want to be able to reload config file without original
Expand Down

0 comments on commit 9695069

Please sign in to comment.