#include <attributes.h>
#include <cassert>
#include <stdexcept>
#include <string>
#include <string_view>
#include <utility>
Go to the source code of this file.
|
#define | STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__) |
|
#define | CHECK_NONFATAL(condition) inline_check_non_fatal(condition, __FILE__, __LINE__, __func__, #condition) |
| Identity function. More...
|
|
#define | Assert(val) inline_assertion_check<true>(val, __FILE__, __LINE__, __func__, #val) |
| Identity function. More...
|
|
#define | Assume(val) inline_assertion_check<false>(val, __FILE__, __LINE__, __func__, #val) |
| Assume is the identity function. More...
|
|
#define | NONFATAL_UNREACHABLE() |
| NONFATAL_UNREACHABLE() is a macro that is used to mark unreachable code. More...
|
|
|
std::string | StrFormatInternalBug (std::string_view msg, std::string_view file, int line, std::string_view func) |
|
template<typename T > |
T && | inline_check_non_fatal (LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion) |
| Helper for CHECK_NONFATAL() More...
|
|
void | assertion_fail (std::string_view file, int line, std::string_view func, std::string_view assertion) |
| Helper for Assert() More...
|
|
template<bool IS_ASSERT, typename T > |
constexpr T && | inline_assertion_check (LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion) |
| Helper for Assert()/Assume() More...
|
|
◆ Assert
Identity function.
Abort if the value compares equal to zero
Definition at line 85 of file check.h.
◆ Assume
Assume is the identity function.
- Should be used to run non-fatal checks. In debug builds it behaves like Assert()/assert() to notify developers and testers about non-fatal errors. In production it doesn't warn or log anything.
- For fatal errors, use Assert().
- For non-fatal errors in interactive sessions (e.g. RPC or command line interfaces), CHECK_NONFATAL() might be more appropriate.
Definition at line 97 of file check.h.
◆ CHECK_NONFATAL
#define CHECK_NONFATAL |
( |
|
condition | ) |
inline_check_non_fatal(condition, __FILE__, __LINE__, __func__, #condition) |
Identity function.
Throw a NonFatalCheckError when the condition evaluates to false
This should only be used
- where the condition is assumed to be true, not for error handling or validating user input
- where a failure to fulfill the condition is recoverable and does not abort the program
For example in RPC code, where it is undesirable to crash the whole program, this can be generally used to replace asserts or recoverable logic errors. A NonFatalCheckError in RPC code is caught and passed as a string to the RPC caller, which can then report the issue to the developers.
Definition at line 81 of file check.h.
◆ NONFATAL_UNREACHABLE
#define NONFATAL_UNREACHABLE |
( |
| ) |
|
◆ STR_INTERNAL_BUG
◆ assertion_fail()
void assertion_fail |
( |
std::string_view |
file, |
|
|
int |
line, |
|
|
std::string_view |
func, |
|
|
std::string_view |
assertion |
|
) |
| |
◆ inline_assertion_check()
template<bool IS_ASSERT, typename T >
constexpr T && inline_assertion_check |
( |
LIFETIMEBOUND T && |
val, |
|
|
const char * |
file, |
|
|
int |
line, |
|
|
const char * |
func, |
|
|
const char * |
assertion |
|
) |
| |
|
constexpr |
◆ inline_check_non_fatal()
template<typename T >
T && inline_check_non_fatal |
( |
LIFETIMEBOUND T && |
val, |
|
|
const char * |
file, |
|
|
int |
line, |
|
|
const char * |
func, |
|
|
const char * |
assertion |
|
) |
| |
◆ StrFormatInternalBug()
std::string StrFormatInternalBug |
( |
std::string_view |
msg, |
|
|
std::string_view |
file, |
|
|
int |
line, |
|
|
std::string_view |
func |
|
) |
| |
◆ G_FUZZING
Initial value:
Definition at line 16 of file check.h.