xrpld
Loading...
Searching...
No Matches
libxrpl/basics/contract.cpp
1#include <xrpl/basics/contract.h>
2
3#include <xrpl/basics/Log.h>
4#include <xrpl/beast/utility/instrumentation.h>
5
6#include <cstdlib>
7#include <iostream>
8#include <string>
9
10namespace xrpl {
11
12void
13logThrow(std::string const& title)
14{
15 JLOG(debugLog().warn()) << title;
16}
17
18[[noreturn]] void
19logicError(std::string const& s) noexcept
20{
21 // LCOV_EXCL_START
22 JLOG(debugLog().fatal()) << s;
23 std::cerr << "Logic error: " << s << std::endl;
24 // Use a non-standard contract naming here (without namespace) because
25 // it's the only location where various unrelated execution paths may
26 // register an error; this is also why the "message" parameter is passed
27 // here.
28 // For the above reasons, we want this contract to stand out.
29 UNREACHABLE("LogicError", {{"message", s}});
30 std::abort();
31 // LCOV_EXCL_STOP
32}
33
34} // namespace xrpl
T abort(T... args)
T endl(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
beast::Journal debugLog()
Returns a debug journal.
Definition Log.cpp:399
void logicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
void logThrow(std::string const &title)
Generates and logs a call stack.