Skip to content

Commit fa27c55

Browse files
author
MarcoFalke
committed
util: Move ResolveErrMsg to util/error
1 parent 8fc7f0c commit fa27c55

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
@@ -822,11 +822,6 @@ void InitParameterInteraction()
822822
}
823823
}
824824

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

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)