xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
basics
contract.h
1
#pragma once
2
3
#include <xrpl/basics/sanitizers.h>
4
#include <xrpl/beast/type_name.h>
5
6
#include <
exception
>
7
#include <
string
>
8
#include <
utility
>
9
10
namespace
xrpl
{
11
12
/* Programming By Contract
13
14
This routines are used when checking
15
preconditions, postconditions, and invariants.
16
*/
17
21
void
22
logThrow
(std::string
const
& title);
23
35
[[noreturn]] XRPL_NO_SANITIZE_ADDRESS
inline
void
36
rethrow
()
37
{
38
logThrow
(
"Re-throwing exception"
);
39
throw
;
40
}
41
42
/*
43
Logs and throws an exception of type E.
44
45
ASAN can't handle sudden jumps in control flow very well. This
46
function is marked as XRPL_NO_SANITIZE_ADDRESS to prevent it from
47
triggering false positives, since it throws.
48
*/
49
50
template
<
class
E,
class
... Args>
51
[[noreturn]] XRPL_NO_SANITIZE_ADDRESS
inline
void
52
Throw
(Args&&... args)
53
{
54
static_assert
(
55
std::is_convertible_v<E*, std::exception*>
,
"Exception must derive from std::exception."
);
56
57
E e(
std::forward<Args>
(args)...);
58
logThrow
(
std::string
(
"Throwing exception of type "
+
beast::typeName<E>
() +
": "
) + e.what());
59
throw
std::move(e);
60
}
61
65
[[noreturn]]
void
66
logicError
(
std::string
const
& how)
noexcept
;
67
68
}
// namespace xrpl
std::string
exception
std::forward
T forward(T... args)
std::is_convertible_v
T is_convertible_v
beast::typeName
std::string typeName()
Definition
type_name.h:16
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::logicError
void logicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
Definition
libxrpl/basics/contract.cpp:19
xrpl::rethrow
XRPL_NO_SANITIZE_ADDRESS void rethrow()
Rethrow the exception currently being handled.
Definition
contract.h:36
xrpl::logThrow
void logThrow(std::string const &title)
Generates and logs a call stack.
Definition
libxrpl/basics/contract.cpp:13
xrpl::Throw
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Definition
contract.h:52
string
utility
Generated by
1.17.0