aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2020-06-05 14:26:16 +0200
committerWladimir J. van der Laan <laanwj@protonmail.com>2020-06-09 15:39:44 +0200
commit77b79fa6ef60d363ca720cef5473f1a2c45099a3 (patch)
treee3cc8ae26b3505c07c87a5060973deaed5e71aef /src/util
parenta79bca2f1fb25f433d6e100a31a3acfde2656ce1 (diff)
downloadbitcoin-77b79fa6ef60d363ca720cef5473f1a2c45099a3.tar.xz
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.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/error.cpp26
-rw-r--r--src/util/error.h4
2 files changed, 15 insertions, 15 deletions
diff --git a/src/util/error.cpp b/src/util/error.cpp
index 72a6e87cde..c4d9ffd037 100644
--- a/src/util/error.cpp
+++ b/src/util/error.cpp
@@ -8,37 +8,37 @@
#include <util/system.h>
#include <util/translation.h>
-std::string TransactionErrorString(const TransactionError err)
+bilingual_str TransactionErrorString(const TransactionError err)
{
switch (err) {
case TransactionError::OK:
- return "No error";
+ return Untranslated("No error");
case TransactionError::MISSING_INPUTS:
- return "Missing inputs";
+ return Untranslated("Missing inputs");
case TransactionError::ALREADY_IN_CHAIN:
- return "Transaction already in block chain";
+ return Untranslated("Transaction already in block chain");
case TransactionError::P2P_DISABLED:
- return "Peer-to-peer functionality missing or disabled";
+ return Untranslated("Peer-to-peer functionality missing or disabled");
case TransactionError::MEMPOOL_REJECTED:
- return "Transaction rejected by AcceptToMemoryPool";
+ return Untranslated("Transaction rejected by AcceptToMemoryPool");
case TransactionError::MEMPOOL_ERROR:
- return "AcceptToMemoryPool failed";
+ return Untranslated("AcceptToMemoryPool failed");
case TransactionError::INVALID_PSBT:
- return "PSBT is not sane";
+ return Untranslated("PSBT is not sane");
case TransactionError::PSBT_MISMATCH:
- return "PSBTs not compatible (different transactions)";
+ return Untranslated("PSBTs not compatible (different transactions)");
case TransactionError::SIGHASH_MISMATCH:
- return "Specified sighash value does not match existing value";
+ return Untranslated("Specified sighash value does not match existing value");
case TransactionError::MAX_FEE_EXCEEDED:
- return "Fee exceeds maximum configured by -maxtxfee";
+ return Untranslated("Fee exceeds maximum configured by -maxtxfee");
// no default case, so the compiler can warn about missing cases
}
assert(false);
}
-std::string ResolveErrMsg(const std::string& optname, const std::string& strBind)
+bilingual_str ResolveErrMsg(const std::string& optname, const std::string& strBind)
{
- return strprintf(_("Cannot resolve -%s address: '%s'").translated, optname, strBind);
+ return strprintf(_("Cannot resolve -%s address: '%s'"), optname, strBind);
}
bilingual_str AmountHighWarn(const std::string& optname)
diff --git a/src/util/error.h b/src/util/error.h
index 61af88ddea..b9830c9eea 100644
--- a/src/util/error.h
+++ b/src/util/error.h
@@ -32,9 +32,9 @@ enum class TransactionError {
MAX_FEE_EXCEEDED,
};
-std::string TransactionErrorString(const TransactionError error);
+bilingual_str TransactionErrorString(const TransactionError error);
-std::string ResolveErrMsg(const std::string& optname, const std::string& strBind);
+bilingual_str ResolveErrMsg(const std::string& optname, const std::string& strBind);
bilingual_str AmountHighWarn(const std::string& optname);