mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
refactor: Error message bilingual_str consistency
- Move the decision whether to translate an error message to where it is defined. This simplifies call sites: no more `InitError(Untranslated(...))`. - Make all functions in `util/error.h` consistently return a `bilingual_str`. We've decided to use this as error message type so let's roll with it. This has no functional changes: no messages are changed, no new translation messages are defined.
This commit is contained in:
@@ -17,7 +17,7 @@ const std::vector<std::string> NET_PERMISSIONS_DOC{
|
||||
};
|
||||
|
||||
// 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, bilingual_str& error)
|
||||
{
|
||||
NetPermissionFlags flags = PF_NONE;
|
||||
const auto atSeparator = str.find('@');
|
||||
@@ -48,7 +48,7 @@ bool TryParsePermissionFlags(const std::string str, NetPermissionFlags& output,
|
||||
else if (permission == "relay") NetPermissions::AddFlag(flags, PF_RELAY);
|
||||
else if (permission.length() == 0); // Allow empty entries
|
||||
else {
|
||||
error = strprintf(_("Invalid P2P permission: '%s'").translated, permission);
|
||||
error = strprintf(_("Invalid P2P permission: '%s'"), permission);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ bool TryParsePermissionFlags(const std::string str, NetPermissionFlags& output,
|
||||
}
|
||||
|
||||
output = flags;
|
||||
error = "";
|
||||
error = Untranslated("");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ std::vector<std::string> NetPermissions::ToStrings(NetPermissionFlags flags)
|
||||
return strings;
|
||||
}
|
||||
|
||||
bool NetWhitebindPermissions::TryParse(const std::string str, NetWhitebindPermissions& output, std::string& error)
|
||||
bool NetWhitebindPermissions::TryParse(const std::string str, NetWhitebindPermissions& output, bilingual_str& error)
|
||||
{
|
||||
NetPermissionFlags flags;
|
||||
size_t offset;
|
||||
@@ -84,17 +84,17 @@ bool NetWhitebindPermissions::TryParse(const std::string str, NetWhitebindPermis
|
||||
return false;
|
||||
}
|
||||
if (addrBind.GetPort() == 0) {
|
||||
error = strprintf(_("Need to specify a port with -whitebind: '%s'").translated, strBind);
|
||||
error = strprintf(_("Need to specify a port with -whitebind: '%s'"), strBind);
|
||||
return false;
|
||||
}
|
||||
|
||||
output.m_flags = flags;
|
||||
output.m_service = addrBind;
|
||||
error = "";
|
||||
error = Untranslated("");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NetWhitelistPermissions::TryParse(const std::string str, NetWhitelistPermissions& output, std::string& error)
|
||||
bool NetWhitelistPermissions::TryParse(const std::string str, NetWhitelistPermissions& output, bilingual_str& error)
|
||||
{
|
||||
NetPermissionFlags flags;
|
||||
size_t offset;
|
||||
@@ -104,12 +104,12 @@ bool NetWhitelistPermissions::TryParse(const std::string str, NetWhitelistPermis
|
||||
CSubNet subnet;
|
||||
LookupSubNet(net, subnet);
|
||||
if (!subnet.IsValid()) {
|
||||
error = strprintf(_("Invalid netmask specified in -whitelist: '%s'").translated, net);
|
||||
error = strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net);
|
||||
return false;
|
||||
}
|
||||
|
||||
output.m_flags = flags;
|
||||
output.m_subnet = subnet;
|
||||
error = "";
|
||||
error = Untranslated("");
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user