mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-09 12:08:17 +03:00
Make assertion print an error if it fails.
This commit is contained in:
parent
dc11d354b2
commit
4eca2f5826
1 changed files with 11 additions and 7 deletions
|
@ -8,13 +8,6 @@ constexpr bool DebugBuild = false;
|
|||
#include <string_view>
|
||||
#include <iostream>
|
||||
|
||||
inline void assertion(const bool& expr, const char* msg)
|
||||
{
|
||||
if constexpr (DebugBuild) {
|
||||
if (!expr) throw std::runtime_error(msg);
|
||||
}
|
||||
};
|
||||
|
||||
enum class LogLevel
|
||||
{
|
||||
Error,
|
||||
|
@ -36,4 +29,15 @@ class TENScriptException : public std::runtime_error
|
|||
{
|
||||
public:
|
||||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
|
||||
inline void assertion(const bool& expr, const char* msg)
|
||||
{
|
||||
if constexpr (DebugBuild) {
|
||||
if (!expr)
|
||||
{
|
||||
TENLog(msg, LogLevel::Error);
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue