debug.h
24 lines
| 678 B
| text/x-c
|
CLexer
r2 | #ifndef DEBUG_H | |||
#define DEBUG_H | ||||
r9 | #include <string> | |||
#include <iostream> | ||||
#include <typeinfo> | ||||
#include <assert.h> | ||||
template <class T, bool crash> | ||||
void SciQLopError(const std::string& message, int line, const std::string& file) | ||||
{ | ||||
std::cerr << "Error in " << file << ", class:" << typeid(T).name() << ", line: " << line << | ||||
std::endl << "Message: " << message << std::endl; | ||||
if constexpr(crash) | ||||
throw; | ||||
} | ||||
r2 | ||||
#ifdef SCIQLOP_CRASH_ON_ERROR | ||||
r9 | #define SCIQLOP_ERROR(CLASS, MESSAGE) SciQLopError<CLASS, true>(MESSAGE, __LINE__, __FILE__) | |||
r2 | #else | |||
r9 | #define SCIQLOP_ERROR(CLASS, MESSAGE) SciQLopError<CLASS, false>(MESSAGE, __LINE__, __FILE__) | |||
r2 | #endif | |||
r9 | ||||
r2 | #endif | |||