15#ifndef LIBCARNAEXCEPTION_H_6014714286
16#define LIBCARNAEXCEPTION_H_6014714286
52 const std::unique_ptr< Details > pimpl;
58 LibCarnaException(
const std::string& type,
const std::string& message,
const std::string& details =
"" );
171 #define LIBCARNA_BREAK_FOR_DEBUG \
172 if( ::LibCarna::base::BreakForDebug::isEnabled() ) \
177 #define LIBCARNA_BREAK_FOR_DEBUG \
178 if( ::LibCarna::base::BreakForDebug::isEnabled() ) \
180 std::raise( SIGINT ); \
184 #define LIBCARNA_BREAK_FOR_DEBUG
198#define LIBCARNA_FAIL( description ) \
199 LIBCARNA_BREAK_FOR_DEBUG \
201 std::stringstream details; \
203 << "Description: " << description << std::endl \
204 << "Where: " << __FILE__ << ":" << __LINE__; \
205 throw ::LibCarna::base::AssertionFailure( details.str() ); \
220#define LIBCARNA_ASSERT( expression ) \
221 if( !( expression ) ) \
223 LIBCARNA_BREAK_FOR_DEBUG \
224 std::stringstream details; \
226 << "Failed expression: " << #expression << std::endl \
227 << "Where: " << __FILE__ << ":" << __LINE__; \
228 throw ::LibCarna::base::AssertionFailure( details.str() ); \
243#define LIBCARNA_ASSERT_EX( expression, description ) \
244 if( !( expression ) ) \
246 LIBCARNA_BREAK_FOR_DEBUG \
247 std::stringstream details; \
249 << "Failed expression: " << #expression << std::endl \
250 << "Description: " << description << std::endl \
251 << "Where: " << __FILE__ << ":" << __LINE__; \
252 throw ::LibCarna::base::AssertionFailure( details.str() ); \
Contains forward-declarations.
Carna exception that indicates a failed assertion.
AssertionFailure(const std::string &details)
Instantiates.
Represents an association.
Controls whether the LIBCARNA_BREAK_FOR_DEBUG macro produces a break point or not.
static void enable()
Makes future invocations of LIBCARNA_BREAK_FOR_DEBUG will produce break point.
static void disable()
Prevents future invocations of LIBCARNA_BREAK_FOR_DEBUG from producing break point.
static bool isEnabled()
Tells whether future invocations of LIBCARNA_BREAK_FOR_DEBUG will produce break point.
Base exception class that provides distinct attributes for the type (category) of the exception,...
const std::string type
Tells the type (category) of this exception.
const char * what() const
Tells the message and the details of this exception.
const std::string message
Tells the message of this exception.
LibCarnaException(const LibCarnaException &other)
Instantiates as a copy of the other exception.
LibCarnaException(const std::string &type, const std::string &message, const std::string &details="")
Initializes the attributes plainly from the arguments.
const std::string details
Tells the details of this exception. May be empty.
LibCarnaException(const std::logic_error &error, const std::string &details="")
Initializes the type as ''Assertion Error'' and the message from the given exception.
LibCarnaException(const std::runtime_error &error, const std::string &details="")
Initializes the type as ''Unhandled Exception'' and the message from the given exception.