Skip to content

Commit 21a1653

Browse files
author
MarcoFalke
committed
Merge #16620: util: Move ResolveErrMsg to util/error
fa27c55 util: Move ResolveErrMsg to util/error (MarcoFalke) Pull request description: Pull request bitcoin/bitcoin#16248 (comment) 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 fa27c55 Tree-SHA512: e2b25ae05082fe9d0ee94bdc7d51f801bd9f78e8fc2b141e9a313e008dbb8a77653fe876e111c802c676859c6b76c37a673d1f8cfbe7ad25607a5ffcffde19fd
2 parents 93bacb8 + fa27c55 commit 21a1653

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/init.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -824,11 +824,6 @@ void InitParameterInteraction()
824824
}
825825
}
826826

827-
static std::string ResolveErrMsg(const char * const optname, const std::string& strBind)
828-
{
829-
return strprintf(_("Cannot resolve -%s address: '%s'").translated, optname, strBind);
830-
}
831-
832827
/**
833828
* Initialize global loggers.
834829
*

src/net_permissions.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <net_permissions.h>
6+
#include <netbase.h>
7+
#include <util/error.h>
68
#include <util/system.h>
79
#include <util/translation.h>
8-
#include <netbase.h>
910

1011
// The parse the following format "perm1,perm2@xxxxxx"
1112
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
7172
const std::string strBind = str.substr(offset);
7273
CService addrBind;
7374
if (!Lookup(strBind.c_str(), addrBind, 0, false)) {
74-
error = strprintf(_("Cannot resolve -%s address: '%s'").translated, "whitebind", strBind);
75+
error = ResolveErrMsg("whitebind", strBind);
7576
return false;
7677
}
7778
if (addrBind.GetPort() == 0) {

src/util/error.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@ std::string TransactionErrorString(const TransactionError err)
3636
assert(false);
3737
}
3838

39+
std::string ResolveErrMsg(const std::string& optname, const std::string& strBind)
40+
{
41+
return strprintf(_("Cannot resolve -%s address: '%s'").translated, optname, strBind);
42+
}
43+
3944
std::string AmountHighWarn(const std::string& optname)
4045
{
4146
return strprintf(_("%s is set very high!").translated, optname);
4247
}
4348

44-
std::string AmountErrMsg(const char* const optname, const std::string& strValue)
49+
std::string AmountErrMsg(const std::string& optname, const std::string& strValue)
4550
{
4651
return strprintf(_("Invalid amount for -%s=<amount>: '%s'").translated, optname, strValue);
4752
}

src/util/error.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* string functions. Types and functions defined here should not require any
1111
* outside dependencies.
1212
*
13-
* Error types defined here can be used in different parts of the bitcoin
13+
* Error types defined here can be used in different parts of the
1414
* codebase, to avoid the need to write boilerplate code catching and
1515
* translating errors passed across wallet/node/rpc/gui code boundaries.
1616
*/
@@ -32,8 +32,10 @@ enum class TransactionError {
3232

3333
std::string TransactionErrorString(const TransactionError error);
3434

35+
std::string ResolveErrMsg(const std::string& optname, const std::string& strBind);
36+
3537
std::string AmountHighWarn(const std::string& optname);
3638

37-
std::string AmountErrMsg(const char* const optname, const std::string& strValue);
39+
std::string AmountErrMsg(const std::string& optname, const std::string& strValue);
3840

3941
#endif // BITCOIN_UTIL_ERROR_H

0 commit comments

Comments
 (0)