mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-04 10:07:27 -05:00
77b79fa6ef
- 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.
52 lines
2.1 KiB
C++
52 lines
2.1 KiB
C++
// Copyright (c) 2010-2019 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <util/error.h>
|
|
|
|
#include <tinyformat.h>
|
|
#include <util/system.h>
|
|
#include <util/translation.h>
|
|
|
|
bilingual_str TransactionErrorString(const TransactionError err)
|
|
{
|
|
switch (err) {
|
|
case TransactionError::OK:
|
|
return Untranslated("No error");
|
|
case TransactionError::MISSING_INPUTS:
|
|
return Untranslated("Missing inputs");
|
|
case TransactionError::ALREADY_IN_CHAIN:
|
|
return Untranslated("Transaction already in block chain");
|
|
case TransactionError::P2P_DISABLED:
|
|
return Untranslated("Peer-to-peer functionality missing or disabled");
|
|
case TransactionError::MEMPOOL_REJECTED:
|
|
return Untranslated("Transaction rejected by AcceptToMemoryPool");
|
|
case TransactionError::MEMPOOL_ERROR:
|
|
return Untranslated("AcceptToMemoryPool failed");
|
|
case TransactionError::INVALID_PSBT:
|
|
return Untranslated("PSBT is not sane");
|
|
case TransactionError::PSBT_MISMATCH:
|
|
return Untranslated("PSBTs not compatible (different transactions)");
|
|
case TransactionError::SIGHASH_MISMATCH:
|
|
return Untranslated("Specified sighash value does not match existing value");
|
|
case TransactionError::MAX_FEE_EXCEEDED:
|
|
return Untranslated("Fee exceeds maximum configured by -maxtxfee");
|
|
// no default case, so the compiler can warn about missing cases
|
|
}
|
|
assert(false);
|
|
}
|
|
|
|
bilingual_str ResolveErrMsg(const std::string& optname, const std::string& strBind)
|
|
{
|
|
return strprintf(_("Cannot resolve -%s address: '%s'"), optname, strBind);
|
|
}
|
|
|
|
bilingual_str AmountHighWarn(const std::string& optname)
|
|
{
|
|
return strprintf(_("%s is set very high!"), optname);
|
|
}
|
|
|
|
bilingual_str AmountErrMsg(const std::string& optname, const std::string& strValue)
|
|
{
|
|
return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue);
|
|
}
|