12#ifndef CARNAEXCEPTION_H_6014714286
13#define CARNAEXCEPTION_H_6014714286
21#include <Carna/Carna.h>
53 CarnaException(
const std::string& type,
const std::string& message,
const std::string& details =
"" );
57 CarnaException(
const std::logic_error& error,
const std::string& details =
"" );
61 CarnaException(
const std::runtime_error& error,
const std::string& details =
"" );
160 #define CARNA_BREAK_FOR_DEBUG \
161 if( ::Carna::base::BreakForDebug::isEnabled() ) \
166 #define CARNA_BREAK_FOR_DEBUG \
167 if( ::Carna::base::BreakForDebug::isEnabled() ) \
169 std::raise( SIGINT ); \
173 #define CARNA_BREAK_FOR_DEBUG
188#define CARNA_FAIL( description ) \
189 CARNA_BREAK_FOR_DEBUG \
191 std::stringstream details; \
193 << "Description: " << description << std::endl \
194 << "File: " << __FILE__ << std::endl \
195 << "Line: " << __LINE__; \
196 throw ::Carna::base::AssertionFailure( details.str() ); \
212#define CARNA_ASSERT( expression ) \
213 if( !( expression ) ) \
215 CARNA_BREAK_FOR_DEBUG \
216 std::stringstream details; \
218 << "Failed expression: " << #expression << std::endl \
219 << "File: " << __FILE__ << std::endl \
220 << "Line: " << __LINE__; \
221 throw ::Carna::base::AssertionFailure( details.str() ); \
237#define CARNA_ASSERT_EX( expression, description ) \
238 if( !( expression ) ) \
240 CARNA_BREAK_FOR_DEBUG \
241 std::stringstream details; \
243 << "Failed expression: " << #expression << std::endl \
244 << "Description: " << description << std::endl \
245 << "File: " << __FILE__ << std::endl \
246 << "Line: " << __LINE__; \
247 throw ::Carna::base::AssertionFailure( details.str() ); \
Carna exception that indicates a failed assertion.
AssertionFailure(const std::string &details)
Instantiates.
Controls whether the CARNA_BREAK_FOR_DEBUG macro produces a break point or not.
static void disable()
Prevents future invocations of CARNA_BREAK_FOR_DEBUG from producing break point.
static bool isEnabled()
Tells whether future invocations of CARNA_BREAK_FOR_DEBUG will produce break point.
static void enable()
Makes future invocations of CARNA_BREAK_FOR_DEBUG will produce break point.
Base exception class that provides distinct attributes for the type (category) of the exception,...
CarnaException(const std::runtime_error &error, const std::string &details="")
Initializes the type as ''Unhandled Exception'' and the message from the given exception.
const std::string details
Tells the details of this exception. May be empty.
CarnaException(const std::logic_error &error, const std::string &details="")
Initializes the type as ''Assertion Error'' and the message from the given exception.
CarnaException(const std::string &type, const std::string &message, const std::string &details="")
Initializes the attributes plainly from the arguments.
const std::string message
Tells the message of this exception.
const std::string type
Tells the type (category) of this exception.