Bitcoin Core  0.19.99
P2P Digital Currency
Classes | Macros
check.h File Reference
#include <tinyformat.h>
#include <stdexcept>
Include dependency graph for check.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  NonFatalCheckError
 

Macros

#define CHECK_NONFATAL(condition)
 Throw a NonFatalCheckError when the condition evaluates to false. More...
 

Macro Definition Documentation

◆ CHECK_NONFATAL

#define CHECK_NONFATAL (   condition)
Value:
do { \
if (!(condition)) { \
strprintf("%s:%d (%s)\n" \
"Internal bug detected: '%s'\n" \
"You may report this issue here: %s\n", \
__FILE__, __LINE__, __func__, \
(#condition), \
} \
} while (false)
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
#define PACKAGE_BUGREPORT

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 undersirable 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 28 of file check.h.