#include <cstdlib>
#include <exception>
#include <iostream>
#include <string>
#include <sstream>
#include "info.hpp"
Go to the source code of this file.
|
| #define | NF_ERROR_MESSAGE(message) |
| | Builds an error message fragment with the message, file, and line. The stack trace is emitted separately by logFatal()/terminate().
|
| #define | NF_ERROR_EXIT(message) |
| | Macro for printing an error message and aborting the program.
|
| #define | NF_THROW(message) |
| | Macro for throwing a NeoNException with the specified error message.
|
| #define | NF_ASSERT(condition, message) |
| | Macro for asserting a condition and printing an error message if the condition is false.
|
| #define | NF_ASSERT_THROW(condition, message) |
| | Macro for asserting a condition and throwing a NeoNException if the condition is false.
|
| #define | NF_DEBUG_ASSERT(condition, message) |
| | Macro for asserting a condition and printing an error message if the condition is false (only in debug mode).
|
| #define | NF_DEBUG_ASSERT_THROW(condition, message) |
| | Macro for asserting a condition and throwing a NeoNException if the condition is false (only in debug mode).
|
| #define | NF_ASSERT_EQUAL(a, b) |
| | Macro for asserting that two values are equal and printing an error message if they are not.
|
| #define | NF_DEBUG_ASSERT_EQUAL(a, b) |
| | Macro for asserting that two values are equal and printing an error message if they are not (only in debug mode).
|
| #define | NF_ASSERT_EQUAL_THROW(a, b) |
| | Macro for asserting that two values are equal and throwing a NeoNException if they are not.
|
| #define | NF_DEBUG_ASSERT_EQUAL_THROW(a, b) |
| | Macro for asserting that two values are equal and throwing a NeoNException if they are not (only in debug mode).
|
◆ NF_ASSERT
| #define NF_ASSERT |
( |
| condition, |
|
|
| message ) |
Value: do \
{ \
if (!(condition)) [[unlikely]] \
{ \
NF_ERROR_EXIT( \
"Assertion `" #condition " in " << __FILE__ << ":" << __LINE__ \
<< "` failed.\n " << message \
); \
} \
} \
while (false)
Macro for asserting a condition and printing an error message if the condition is false.
This macro checks the specified condition and, if it evaluates to false, prints an error message to the standard error stream, including the current file name and current line number, and then calls std::abort() to terminate the program.
- Parameters
-
| condition | The condition to be checked. |
| message | The error message to be printed if the condition is false. |
Definition at line 118 of file error.hpp.
◆ NF_ASSERT_EQUAL
| #define NF_ASSERT_EQUAL |
( |
| a, |
|
|
| b ) |
Value:NF_ASSERT(a == b,
"Expected " << b <<
", got " << a)
#define NF_ASSERT(condition, message)
Macro for asserting a condition and printing an error message if the condition is false.
Macro for asserting that two values are equal and printing an error message if they are not.
This macro checks that the two specified values are equal and, if they are not, prints an error message to the standard error stream, including the expected and actual values, the current file name, and the current line number, and then calls std::abort() to terminate the program.
- Parameters
-
| a | The actual value to be compared. |
| b | The expected value to be compared. |
Definition at line 218 of file error.hpp.
◆ NF_ASSERT_EQUAL_THROW
| #define NF_ASSERT_EQUAL_THROW |
( |
| a, |
|
|
| b ) |
Value:
#define NF_ASSERT_THROW(condition, message)
Macro for asserting a condition and throwing a NeoNException if the condition is false.
Macro for asserting that two values are equal and throwing a NeoNException if they are not.
This macro checks that the two specified values are equal and, if they are not, constructs a std::stringstream to concatenate the expected and actual values with the current file name and current line number, and then throws a NeoNException with the resulting string as the error message.
- Parameters
-
| a | The actual value to be compared. |
| b | The expected value to be compared. |
Definition at line 245 of file error.hpp.
◆ NF_ASSERT_THROW
| #define NF_ASSERT_THROW |
( |
| condition, |
|
|
| message ) |
Value: do \
{ \
if (!(condition)) [[unlikely]] \
{ \
NF_THROW("Assertion `" #condition "` failed.\n " << message); \
} \
} \
while (false)
Macro for asserting a condition and throwing a NeoNException if the condition is false.
This macro checks the specified condition and, if it evaluates to false, constructs a std::stringstream to concatenate the specified error message with the current file name and current line number, and then throws a NeoNException with the resulting string as the error message.
- Parameters
-
| condition | The condition to be checked. |
| message | The error message to be included in the exception if the condition is false. |
Definition at line 144 of file error.hpp.
◆ NF_DEBUG_ASSERT
| #define NF_DEBUG_ASSERT |
( |
| condition, |
|
|
| message ) |
Value:
Macro for asserting a condition and printing an error message if the condition is false (only in debug mode).
This macro does nothing in release mode.
- Parameters
-
| condition | The condition to be checked. |
| message | The error message to be printed if the condition is false. |
Definition at line 190 of file error.hpp.
◆ NF_DEBUG_ASSERT_EQUAL
| #define NF_DEBUG_ASSERT_EQUAL |
( |
| a, |
|
|
| b ) |
Value:
#define NF_DEBUG_ASSERT(condition, message)
Macro for asserting a condition and printing an error message if the condition is false (only in debu...
Macro for asserting that two values are equal and printing an error message if they are not (only in debug mode).
This macro is equivalent to NF_ASSERT_EQUAL in debug mode.
- Parameters
-
| a | The actual value to be compared. |
| b | The expected value to be compared. |
Definition at line 230 of file error.hpp.
◆ NF_DEBUG_ASSERT_EQUAL_THROW
| #define NF_DEBUG_ASSERT_EQUAL_THROW |
( |
| a, |
|
|
| b ) |
Value:
#define NF_DEBUG_ASSERT_THROW(condition, message)
Macro for asserting a condition and throwing a NeoNException if the condition is false (only in debug...
Macro for asserting that two values are equal and throwing a NeoNException if they are not (only in debug mode).
This macro is equivalent to NF_ASSERT_EQUAL_THROW in debug mode.
- Parameters
-
| a | The actual value to be compared. |
| b | The expected value to be compared. |
Definition at line 257 of file error.hpp.
◆ NF_DEBUG_ASSERT_THROW
| #define NF_DEBUG_ASSERT_THROW |
( |
| condition, |
|
|
| message ) |
Value:
Macro for asserting a condition and throwing a NeoNException if the condition is false (only in debug mode).
This macro does nothing in release mode.
- Parameters
-
| condition | The condition to be checked. |
| message | The error message to be included in the exception if the condition is false. |
Definition at line 203 of file error.hpp.
◆ NF_ERROR_EXIT
| #define NF_ERROR_EXIT |
( |
| message | ) |
|
Value:
#define NF_ERROR_MESSAGE(message)
Builds an error message fragment with the message, file, and line. The stack trace is emitted separat...
void logFatal(const std::string &message)
Macro for printing an error message and aborting the program.
This macro prints the specified error message to the standard error stream, including the current file name and current line number, and then calls std::abort() to terminate the program.
- Parameters
-
| message | The error message to be printed. |
Definition at line 90 of file error.hpp.
◆ NF_ERROR_MESSAGE
| #define NF_ERROR_MESSAGE |
( |
| message | ) |
|
Value: "Error: " << message << "\nFile: " << __FILE__ << "\nLine: " << __LINE__ << "\n"
Builds an error message fragment with the message, file, and line. The stack trace is emitted separately by logFatal()/terminate().
- Parameters
-
| message | The error message to be included in the generated message. |
Definition at line 74 of file error.hpp.
◆ NF_THROW
| #define NF_THROW |
( |
| message | ) |
|
Value:
Custom exception class for NeoN.
Macro for throwing a NeoNException with the specified error message.
This macro constructs a std::stringstream to concatenate the specified error message with the current file name and current line number, and then throws a NeoNException with the resulting string as the error message.
- Parameters
-
| message | The error message to be included in the exception. |
Definition at line 103 of file error.hpp.