LibCarna Version 3.4.0
Loading...
Searching...
No Matches
Classes | Namespaces | Macros
LibCarnaException.hpp File Reference

Defines LibCarna::base::LibCarnaException and LibCarna::base::AssertionFailure. More...

#include <memory>
#include <LibCarna/LibCarna.hpp>
#include <string>
#include <sstream>
#include <stdexcept>
#include <csignal>
+ Include dependency graph for LibCarnaException.hpp:

Go to the source code of this file.

Classes

class  LibCarna::base::LibCarnaException
 Base exception class that provides distinct attributes for the type (category) of the exception, a message and an optional details section. More...
 
class  LibCarna::base::AssertionFailure
 Carna exception that indicates a failed assertion. More...
 
class  LibCarna::base::BreakForDebug
 Controls whether the LIBCARNA_BREAK_FOR_DEBUG macro produces a break point or not. More...
 

Namespaces

namespace  LibCarna::base
 Contains the core framework components.
 

Macros

#define LIBCARNA_BREAK_FOR_DEBUG
 Causes a break point in debug mode, does nothing in release mode.
 
#define LIBCARNA_FAIL(description)
 Causes a break point in debug mode and throws an AssertionFailure.
 
#define LIBCARNA_ASSERT(expression)
 If the given expression is false, a break point is raised in debug mode and an AssertionFailure thrown.
 
#define LIBCARNA_ASSERT_EX(expression, description)
 If the given expression is false, a break point is raised in debug mode and an AssertionFailure thrown, description being noted within the exception.
 

Detailed Description

Defines LibCarna::base::LibCarnaException and LibCarna::base::AssertionFailure.

Definition in file LibCarnaException.hpp.

Macro Definition Documentation

◆ LIBCARNA_ASSERT

#define LIBCARNA_ASSERT (   expression)
Value:
if( !( expression ) ) \
{ \
LIBCARNA_BREAK_FOR_DEBUG \
std::stringstream details; \
details \
<< "Failed expression: " << #expression << std::endl \
<< "Where: " << __FILE__ << ":" << __LINE__; \
throw ::LibCarna::base::AssertionFailure( details.str() ); \
}

If the given expression is false, a break point is raised in debug mode and an AssertionFailure thrown.

Author
Leonid Kostrykin

Definition at line 220 of file LibCarnaException.hpp.

◆ LIBCARNA_ASSERT_EX

#define LIBCARNA_ASSERT_EX (   expression,
  description 
)
Value:
if( !( expression ) ) \
{ \
LIBCARNA_BREAK_FOR_DEBUG \
std::stringstream details; \
details \
<< "Failed expression: " << #expression << std::endl \
<< "Description: " << description << std::endl \
<< "Where: " << __FILE__ << ":" << __LINE__; \
throw ::LibCarna::base::AssertionFailure( details.str() ); \
}

If the given expression is false, a break point is raised in debug mode and an AssertionFailure thrown, description being noted within the exception.

Author
Leonid Kostrykin

Definition at line 243 of file LibCarnaException.hpp.

◆ LIBCARNA_BREAK_FOR_DEBUG

#define LIBCARNA_BREAK_FOR_DEBUG
Value:
{ \
std::raise( SIGINT ); \
}
static bool isEnabled()
Tells whether future invocations of LIBCARNA_BREAK_FOR_DEBUG will produce break point.

Causes a break point in debug mode, does nothing in release mode.

See also
The behavior in debug mode can be controlled via the BreakForDebug class.
Author
Leonid Kostrykin

Definition at line 177 of file LibCarnaException.hpp.

◆ LIBCARNA_FAIL

#define LIBCARNA_FAIL (   description)
Value:
{ \
std::stringstream details; \
details \
<< "Description: " << description << std::endl \
<< "Where: " << __FILE__ << ":" << __LINE__; \
throw ::LibCarna::base::AssertionFailure( details.str() ); \
}
#define LIBCARNA_BREAK_FOR_DEBUG
Causes a break point in debug mode, does nothing in release mode.

Causes a break point in debug mode and throws an AssertionFailure.

Author
Leonid Kostrykin

Definition at line 198 of file LibCarnaException.hpp.