cnorxz/src/include/base/assert.h
Christian Zimmermann fcf6712912
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
WIP: doxy
2023-11-01 02:58:05 +01:00

26 lines
806 B
C++

/**
@file include/base/assert.h
@brief warning and error makros
Definition of macros that can be used for convenient error handling and warnings
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#include <iostream>
#include <sstream>
#define CXZ_ERRTAG __FILE__ << '@' << __LINE__ << '(' << __func__ << "): error"
#define CXZ_WARNTAG __FILE__ << '@' << __LINE__ << ": warning"
#define CXZ_ERROR(errmsg) {\
auto mkerr = [&](){ std::stringstream ss; ss << CXZ_ERRTAG << ": " << errmsg << std::flush; return ss.str(); }; \
throw std::runtime_error(mkerr()); }
#define CXZ_WARNING(errmsg) {\
std::cerr << CXZ_WARNTAG << ": " << errmsg << std::endl; }
#define CXZ_ASSERT(statement, errmsg) if(not (statement)) { CXZ_ERROR(errmsg); }