Skip to content

Commit

Permalink
util: Move ResolveErrMsg to util/error
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Aug 15, 2019
1 parent 70c4a7a commit 7160c34
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
5 changes: 0 additions & 5 deletions src/init.cpp
Expand Up @@ -822,11 +822,6 @@ void InitParameterInteraction()
}
}

static std::string ResolveErrMsg(const char * const optname, const std::string& strBind)
{
return strprintf(_("Cannot resolve -%s address: '%s'").translated, optname, strBind);
}

/**
* Initialize global loggers.
*
Expand Down
5 changes: 3 additions & 2 deletions src/net_permissions.cpp
Expand Up @@ -3,9 +3,10 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <net_permissions.h>
#include <netbase.h>
#include <util/error.h>
#include <util/system.h>
#include <util/translation.h>
#include <netbase.h>

// The parse the following format "perm1,perm2@xxxxxx"
bool TryParsePermissionFlags(const std::string str, NetPermissionFlags& output, size_t& readen, std::string& error)
Expand Down Expand Up @@ -71,7 +72,7 @@ bool NetWhitebindPermissions::TryParse(const std::string str, NetWhitebindPermis
const std::string strBind = str.substr(offset);
CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, 0, false)) {
error = strprintf(_("Cannot resolve -%s address: '%s'").translated, "whitebind", strBind);
error = ResolveErrMsg("whitebind", strBind);
return false;
}
if (addrBind.GetPort() == 0) {
Expand Down
7 changes: 6 additions & 1 deletion src/util/error.cpp
Expand Up @@ -36,12 +36,17 @@ std::string TransactionErrorString(const TransactionError err)
assert(false);
}

std::string ResolveErrMsg(const std::string& optname, const std::string& strBind)
{
return strprintf(_("Cannot resolve -%s address: '%s'").translated, optname, strBind);
}

std::string AmountHighWarn(const std::string& optname)
{
return strprintf(_("%s is set very high!").translated, optname);
}

std::string AmountErrMsg(const char* const optname, const std::string& strValue)
std::string AmountErrMsg(const std::string& optname, const std::string& strValue)
{
return strprintf(_("Invalid amount for -%s=<amount>: '%s'").translated, optname, strValue);
}
6 changes: 4 additions & 2 deletions src/util/error.h
Expand Up @@ -10,7 +10,7 @@
* string functions. Types and functions defined here should not require any
* outside dependencies.
*
* Error types defined here can be used in different parts of the bitcoin
* Error types defined here can be used in different parts of the
* codebase, to avoid the need to write boilerplate code catching and
* translating errors passed across wallet/node/rpc/gui code boundaries.
*/
Expand All @@ -32,8 +32,10 @@ enum class TransactionError {

std::string TransactionErrorString(const TransactionError error);

std::string ResolveErrMsg(const std::string& optname, const std::string& strBind);

std::string AmountHighWarn(const std::string& optname);

std::string AmountErrMsg(const char* const optname, const std::string& strValue);
std::string AmountErrMsg(const std::string& optname, const std::string& strValue);

#endif // BITCOIN_UTIL_ERROR_H

0 comments on commit 7160c34

Please sign in to comment.