diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-08-16 07:53:16 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-08-16 07:53:23 -0400 |
commit | 21a165325eda90fa6eb70ca0b9e3fa23924f5964 (patch) | |
tree | a12a5a972eb1706120aa071e63526849e13b7290 | |
parent | 93bacb8cc9c05010659d9aea463ebac5c1b6bf39 (diff) | |
parent | fa27c55b0593c769b6ad87de0b59df3816d73548 (diff) |
Merge #16620: util: Move ResolveErrMsg to util/error
fa27c55b0593c769b6ad87de0b59df3816d73548 util: Move ResolveErrMsg to util/error (MarcoFalke)
Pull request description:
Pull request https://github.com/bitcoin/bitcoin/pull/16248#discussion_r314035862 duplicated the body of this util function. The whole point of the util function is to be shared, so do that here as a fixup to #16248
ACKs for top commit:
Sjors:
utACK fa27c55
ryanofsky:
utACK fa27c55b0593c769b6ad87de0b59df3816d73548
Tree-SHA512: e2b25ae05082fe9d0ee94bdc7d51f801bd9f78e8fc2b141e9a313e008dbb8a77653fe876e111c802c676859c6b76c37a673d1f8cfbe7ad25607a5ffcffde19fd
-rw-r--r-- | src/init.cpp | 5 | ||||
-rw-r--r-- | src/net_permissions.cpp | 5 | ||||
-rw-r--r-- | src/util/error.cpp | 7 | ||||
-rw-r--r-- | src/util/error.h | 6 |
4 files changed, 13 insertions, 10 deletions
diff --git a/src/init.cpp b/src/init.cpp index d98f7c3767..dce601a554 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -824,11 +824,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. * diff --git a/src/net_permissions.cpp b/src/net_permissions.cpp index 736f19293a..ef6c40ce20 100644 --- a/src/net_permissions.cpp +++ b/src/net_permissions.cpp @@ -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) @@ -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) { diff --git a/src/util/error.cpp b/src/util/error.cpp index 9edb7dc533..287476c0d3 100644 --- a/src/util/error.cpp +++ b/src/util/error.cpp @@ -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); } diff --git a/src/util/error.h b/src/util/error.h index 0fd474b962..7777cc0c5d 100644 --- a/src/util/error.h +++ b/src/util/error.h @@ -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. */ @@ -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 |