The Sparta Modeling Framework
Loading...
Searching...
No Matches
SpartaException.hpp File Reference

Exception class for all of Sparta. More...

#include <exception>
#include <sstream>
#include <string>
#include <memory>

Go to the source code of this file.

Classes

class  sparta::SpartaException
 Used to construct and throw a standard C++ exception. Inherits from std::exception. More...
 
class  sparta::SpartaCriticalError
 Indicates something went seriously wrong and likely indicates corruption in simulator runtime state. More...
 
class  sparta::SpartaFatalError
 Indicates something went seriously wrong and likely indicates unrecoverable corruption in simulator runtime state or misuse. This is the only exception that should ever be generated by a destructor since its semantics are that the simulation should terminate. More...
 

Namespaces

namespace  sparta
 Macros for handling exponential backoff.
 
namespace  sparta::app
 Sparta Application framework.
 

Macros

#define THROW_IF_NOT_UNWINDING(exclass, msg_construct)
 Utility for throwing an exception ONLY if there is not already an uncaught exception causing the stack to unwind. This is useful in destructors or other shutdown operations when testing for premature shutdown conditions. Often, there are shutdown errors if an exception in the program causes premature destruction and throwing a new exception during shutdown would mask the root cause,.
 
#define DO_PRAGMA(x)   _Pragma(#x)
 
#define TERMINATING_THROW(exclass, msg_construct)
 

Detailed Description

Exception class for all of Sparta.

Definition in file SpartaException.hpp.

Macro Definition Documentation

◆ DO_PRAGMA

#define DO_PRAGMA (   x)    _Pragma(#x)

Definition at line 37 of file SpartaException.hpp.

◆ TERMINATING_THROW

#define TERMINATING_THROW (   exclass,
  msg_construct 
)
Value:
DO_PRAGMA(GCC diagnostic push) \
DO_PRAGMA(GCC diagnostic ignored "-Wterminate") \
throw exclass() << msg_construct; \
DO_PRAGMA(GCC diagnostic pop)

Definition at line 38 of file SpartaException.hpp.

◆ THROW_IF_NOT_UNWINDING

#define THROW_IF_NOT_UNWINDING (   exclass,
  msg_construct 
)
Value:
if(std::uncaught_exceptions() > 0){ \
std::cerr << msg_construct << std::endl; \
}else{ \
throw exclass() << msg_construct; \
}

Utility for throwing an exception ONLY if there is not already an uncaught exception causing the stack to unwind. This is useful in destructors or other shutdown operations when testing for premature shutdown conditions. Often, there are shutdown errors if an exception in the program causes premature destruction and throwing a new exception during shutdown would mask the root cause,.

Warning
this should typically ONLY be used for Fatal destructor errors
Deprecated:
this should not be used because std::uncaught_exception() can not fully prevent ending up in a double-exception case as explained in https://akrzemi1.wordpress.com/2011/09/21/destructors-that-throw/

Definition at line 30 of file SpartaException.hpp.