remove wrapper and just use a lambda that throws on non empty value

pull/1306/head
Jeff Becker 4 years ago
parent a0dc2e795c
commit d85c7bc628
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -431,14 +431,14 @@ namespace llarp
conf.defineOption<bool>(
"lokid", "enabled", false, DefaultWhitelistRouters, AssignmentAcceptor(whitelistRouters));
conf.defineOption<std::string>(
"lokid",
"jsonrpc",
false,
"",
InvalidOption<std::string>("the [lokid]::jsonrpc option is deprecated please use the "
"[lokid]::rpc "
"config option instead"));
conf.defineOption<std::string>("lokid", "jsonrpc", false, "", [](std::string arg) {
if (arg.empty())
return;
throw std::invalid_argument(
"the [lokid]::jsonrpc option is deprecated please use the "
"[lokid]::rpc "
"config option instead");
});
conf.defineOption<std::string>(
"lokid", "rpc", false, DefaultLokidRPCAddr, [this](std::string arg) {

@ -448,14 +448,4 @@ namespace llarp
return [&](T arg) mutable { ref = std::move(arg); };
}
/// A wrapper that throws an invalid argument exception if the argument is provided in config
/// the invalid_arugment exception is constructed using a string that holds the exception's
/// message
template <typename T>
std::function<void(T)>
InvalidOption(std::string msg)
{
return [msg](T) mutable { throw std::invalid_argument(msg); };
}
} // namespace llarp

Loading…
Cancel
Save