Loading [MathJax]/extensions/tex2jax.js
Carna  Version 3.3.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Namespaces | Macros
CarnaException.h File Reference

Defines Carna::base::CarnaException, Carna::base::AssertionFailure. More...

#include <Carna/Carna.h>
#include <string>
#include <sstream>
#include <stdexcept>
#include <csignal>
+ Include dependency graph for CarnaException.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Namespaces

 Carna::base
 Contains the core framework components.
 

Macros

#define CARNA_BREAK_FOR_DEBUG
 Causes a break point in debug mode, does nothing in release mode. More...
 
#define CARNA_FAIL(description)
 Causes a break point in debug mode and throws an AssertionFailure. More...
 
#define CARNA_ASSERT(expression)
 If the given expression is false, a break point is raised in debug mode and an AssertionFailure thrown. More...
 
#define CARNA_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. More...
 

Detailed Description

Defines Carna::base::CarnaException, Carna::base::AssertionFailure.

Definition in file CarnaException.h.

Macro Definition Documentation

◆ CARNA_ASSERT

#define CARNA_ASSERT (   expression)
Value:
if( !( expression ) ) \
{ \
CARNA_BREAK_FOR_DEBUG \
std::stringstream details; \
details \
<< "Failed expression: " << #expression << std::endl \
<< "File: " << __FILE__ << std::endl \
<< "Line: " << __LINE__; \
throw ::Carna::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
Date
5.3.13

Definition at line 212 of file CarnaException.h.

◆ CARNA_ASSERT_EX

#define CARNA_ASSERT_EX (   expression,
  description 
)
Value:
if( !( expression ) ) \
{ \
CARNA_BREAK_FOR_DEBUG \
std::stringstream details; \
details \
<< "Failed expression: " << #expression << std::endl \
<< "Description: " << description << std::endl \
<< "File: " << __FILE__ << std::endl \
<< "Line: " << __LINE__; \
throw ::Carna::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
Date
5.3.13

Definition at line 237 of file CarnaException.h.

◆ CARNA_BREAK_FOR_DEBUG

#define CARNA_BREAK_FOR_DEBUG
Value:
{ \
std::raise( SIGINT ); \
}
static bool isEnabled()
Tells whether future invocations of CARNA_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
Date
5.3.13

Definition at line 166 of file CarnaException.h.

◆ CARNA_FAIL

#define CARNA_FAIL (   description)
Value:
{ \
std::stringstream details; \
details \
<< "Description: " << description << std::endl \
<< "File: " << __FILE__ << std::endl \
<< "Line: " << __LINE__; \
throw ::Carna::base::AssertionFailure( details.str() ); \
}
#define CARNA_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
Date
5.3.13

Definition at line 188 of file CarnaException.h.