util: Move ResolveErrMsg to util/error

This commit is contained in:
MarcoFalke 2019-08-15 10:06:23 -04:00
parent 8fc7f0cba9
commit fa27c55b05
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
4 changed files with 13 additions and 10 deletions

View file

@ -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. * Initialize global loggers.
* *

View file

@ -3,9 +3,10 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <net_permissions.h> #include <net_permissions.h>
#include <netbase.h>
#include <util/error.h>
#include <util/system.h> #include <util/system.h>
#include <util/translation.h> #include <util/translation.h>
#include <netbase.h>
// The parse the following format "perm1,perm2@xxxxxx" // The parse the following format "perm1,perm2@xxxxxx"
bool TryParsePermissionFlags(const std::string str, NetPermissionFlags& output, size_t& readen, std::string& error) bool TryParsePermissionFlags(const std::string str, NetPermissionFlags& output, size_t& readen, std::string& error)
@ -71,7 +72,7 @@ bool NetWhitebindPermissions::TryParse(const std::string str, NetWhitebindPermis
const std::string strBind = str.substr(offset); const std::string strBind = str.substr(offset);
CService addrBind; CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, 0, false)) { if (!Lookup(strBind.c_str(), addrBind, 0, false)) {
error = strprintf(_("Cannot resolve -%s address: '%s'").translated, "whitebind", strBind); error = ResolveErrMsg("whitebind", strBind);
return false; return false;
} }
if (addrBind.GetPort() == 0) { if (addrBind.GetPort() == 0) {

View file

@ -36,12 +36,17 @@ std::string TransactionErrorString(const TransactionError err)
assert(false); 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) std::string AmountHighWarn(const std::string& optname)
{ {
return strprintf(_("%s is set very high!").translated, 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); return strprintf(_("Invalid amount for -%s=<amount>: '%s'").translated, optname, strValue);
} }

View file

@ -10,7 +10,7 @@
* string functions. Types and functions defined here should not require any * string functions. Types and functions defined here should not require any
* outside dependencies. * 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 * codebase, to avoid the need to write boilerplate code catching and
* translating errors passed across wallet/node/rpc/gui code boundaries. * translating errors passed across wallet/node/rpc/gui code boundaries.
*/ */
@ -32,8 +32,10 @@ enum class TransactionError {
std::string TransactionErrorString(const TransactionError error); 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 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 #endif // BITCOIN_UTIL_ERROR_H