mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-21 14:20:56 +00:00
Add internal fatal error code
This commit is contained in:
@@ -29,13 +29,8 @@ namespace xrpl {
|
||||
namespace {
|
||||
|
||||
// What a host call answers when it could not be served at all: every method below hands it
|
||||
// to `guarded` as the answer for a body that throws. The engine converts -1 into a fault,
|
||||
// stops the run and reports `tecINTERNAL`, rather than handing the code to the contract.
|
||||
//
|
||||
// Named here because `Unimplemented` is not what a thrown exception is. What -1 carries is
|
||||
// the meaning the two conditions share - "the host could not serve this call, and the
|
||||
// contract has no business interpreting why" - and it is the fate they share too.
|
||||
constexpr std::int32_t kHostInternal = hfErrorToInt(HostFunctionError::Unimplemented);
|
||||
// to `guarded` as the answer for a body that throws.
|
||||
constexpr std::int32_t kHostInternal = hfErrorToInt(HostFunctionError::InternalFatal);
|
||||
|
||||
// Copy `value` into `out` only if the whole of it fits, and answer its true length either
|
||||
// way. A value too large for the guest's buffer must reach it in no part: a prefix would
|
||||
|
||||
@@ -124,7 +124,7 @@ getAnyFieldData(FieldValue const& variantObj)
|
||||
return Bytes((*u)->begin(), (*u)->end());
|
||||
|
||||
// Unreachable: the variant only holds the two alternatives above. If not, it is an
|
||||
// xrpld bug, and `guarded` turns the throw into -1, which stops the run ->
|
||||
// xrpld bug, and `guarded` turns the throw into `InternalFatal`, which stops the run ->
|
||||
// tecINTERNAL.
|
||||
Throw<std::runtime_error>("field value variant holds neither alternative"); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
@@ -292,7 +292,10 @@ TEST_F(WasmVMTest, FatalHostErrorStopsRun)
|
||||
return std::unexpected(refused);
|
||||
});
|
||||
|
||||
for (auto const error : {HostFunctionError::Unimplemented, HostFunctionError::NoMemExported})
|
||||
for (auto const error :
|
||||
{HostFunctionError::InternalFatal,
|
||||
HostFunctionError::Unimplemented,
|
||||
HostFunctionError::NoMemExported})
|
||||
{
|
||||
refused = error;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user