NeoFOAM
WIP Prototype of a modern OpenFOAM core
|
#include <cstdlib>
#include <exception>
#include <iostream>
#include <string>
#include <sstream>
#include "info.hpp"
Go to the source code of this file.
Classes | |
class | NeoFOAM::NeoFOAMException |
Custom exception class for NeoFOAM. More... | |
Namespaces | |
namespace | NeoFOAM |
Macros | |
#define | NF_ERROR_MESSAGE(message) "Error: " << message << "\nFile: " << __FILE__ << "\nLine: " << __LINE__ << "\n" |
Macro for generating an error message without debug information. | |
#define | NF_ERROR_EXIT(message) |
Macro for printing an error message and aborting the program. | |
#define | NF_THROW(message) throw NeoFOAM::NeoFOAMException((std::stringstream() << NF_ERROR_MESSAGE(message)).str()) |
Macro for throwing a NeoFOAMException 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 NeoFOAMException if the condition is false. | |
#define | NF_DEBUG_ASSERT(condition, message) ((void)0) |
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) ((void)0) |
Macro for asserting a condition and throwing a NeoFOAMException if the condition is false (only in debug mode). | |
#define | NF_ASSERT_EQUAL(a, b) NF_ASSERT(a == b, "Expected " << b << ", got " << a) |
Macro for asserting that two values are equal and printing an error message if they are not. | |
#define | NF_DEBUG_ASSERT_EQUAL(a, b) NF_DEBUG_ASSERT(a == b, "Expected " << b << ", got " << a) |
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) NF_ASSERT_THROW(a == b, "Expected " << b << ", got " << a) |
Macro for asserting that two values are equal and throwing a NeoFOAMException if they are not. | |
#define | NF_DEBUG_ASSERT_EQUAL_THROW(a, b) NF_DEBUG_ASSERT_THROW(a == b, "Expected " << b << ", got " << a) |
Macro for asserting that two values are equal and throwing a NeoFOAMException if they are not (only in debug mode). | |
#define NF_ASSERT | ( | condition, | |
message | |||
) |
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.
condition | The condition to be checked. |
message | The error message to be printed if the condition is false. |
#define NF_ASSERT_EQUAL | ( | a, | |
b | |||
) | NF_ASSERT(a == b, "Expected " << b << ", got " << a) |
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.
a | The actual value to be compared. |
b | The expected value to be compared. |
#define NF_ASSERT_EQUAL_THROW | ( | a, | |
b | |||
) | NF_ASSERT_THROW(a == b, "Expected " << b << ", got " << a) |
Macro for asserting that two values are equal and throwing a NeoFOAMException 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 NeoFOAMException with the resulting string as the error message.
a | The actual value to be compared. |
b | The expected value to be compared. |
#define NF_ASSERT_THROW | ( | condition, | |
message | |||
) |
Macro for asserting a condition and throwing a NeoFOAMException 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 NeoFOAMException with the resulting string as the error message.
condition | The condition to be checked. |
message | The error message to be included in the exception if the condition is false. |
#define NF_DEBUG_ASSERT | ( | condition, | |
message | |||
) | ((void)0) |
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.
condition | The condition to be checked. |
message | The error message to be printed if the condition is false. |
#define NF_DEBUG_ASSERT_EQUAL | ( | a, | |
b | |||
) | NF_DEBUG_ASSERT(a == b, "Expected " << b << ", got " << a) |
#define NF_DEBUG_ASSERT_EQUAL_THROW | ( | a, | |
b | |||
) | NF_DEBUG_ASSERT_THROW(a == b, "Expected " << b << ", got " << a) |
Macro for asserting that two values are equal and throwing a NeoFOAMException if they are not (only in debug mode).
This macro is equivalent to NF_ASSERT_EQUAL_THROW in debug mode.
a | The actual value to be compared. |
b | The expected value to be compared. |
#define NF_DEBUG_ASSERT_THROW | ( | condition, | |
message | |||
) | ((void)0) |
Macro for asserting a condition and throwing a NeoFOAMException if the condition is false (only in debug mode).
This macro does nothing in release mode.
condition | The condition to be checked. |
message | The error message to be included in the exception if the condition is false. |
#define NF_ERROR_EXIT | ( | 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.
message | The error message to be printed. |
#define NF_ERROR_MESSAGE | ( | message | ) | "Error: " << message << "\nFile: " << __FILE__ << "\nLine: " << __LINE__ << "\n" |
Macro for generating an error message without debug information.
This macro generates an error message with the specified message, current file name, and current line number.
message | The error message to be included in the generated message. |
#define NF_THROW | ( | message | ) | throw NeoFOAM::NeoFOAMException((std::stringstream() << NF_ERROR_MESSAGE(message)).str()) |
Macro for throwing a NeoFOAMException 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 NeoFOAMException with the resulting string as the error message.
message | The error message to be included in the exception. |