8#include <botan/assert.h>
10#include <botan/exceptn.h>
11#include <botan/internal/fmt.h>
14#if defined(BOTAN_TERMINATE_ON_ASSERTS)
26 throw Invalid_State(
fmt(
"Invalid state: expr {} was false in {}:{}", expr, func, file));
29void assertion_failure(
const char* expr_str,
const char* assertion_made,
const char* func,
const char* file,
int line) {
30 std::ostringstream format;
32 format <<
"False assertion ";
34 if(assertion_made && assertion_made[0] != 0) {
35 format <<
"'" << assertion_made <<
"' (expression " << expr_str <<
") ";
37 format << expr_str <<
" ";
41 format <<
"in " << func <<
" ";
44 format <<
"@" << file <<
":" << line;
46#if defined(BOTAN_TERMINATE_ON_ASSERTS)
47 std::cerr << format.str() <<
'\n';
55 const std::string msg =
fmt(
"Codepath that was marked unreachable was reached @{}:{}", file, line);
57#if defined(BOTAN_TERMINATE_ON_ASSERTS)
58 std::cerr << msg <<
'\n';
void assert_unreachable(const char *file, int line)
void throw_invalid_state(const char *expr, const char *func, const char *file)
void throw_invalid_argument(const char *message, const char *func, const char *file)
std::string fmt(std::string_view format, const T &... args)
void assertion_failure(const char *expr_str, const char *assertion_made, const char *func, const char *file, int line)