SPHinXsys  alpha version
Public Member Functions | Protected Member Functions | List of all members
SPH::Exception Class Reference

A class for basic exception functionality. More...

#include <exception.h>

Inherits exception.

Inherited by SPH::IndexOutOfRange, SPH::InvalidArgument, SPH::InvalidCall, SPH::InvalidTemplateArgument, and SPH::KeyNotFound.

Public Member Functions

 Exception (const std::string &aMsg="", const std::string &aFile="", int aLine=-1)
 Default Constructor. More...
 
 Exception (const std::string &file, size_t line, const std::string &func)
 Call this constructor from derived classes to add file, line and function information to the error message. Use this when throwing Derived classes. Use OPENSIM_THROW_<> macros at throw sites.

 
 Exception (const std::string &file, size_t line, const std::string &func, const std::string &msg)
 Use this when you want to throw an Exception and also provide a message.
 
virtual ~Exception () throw ()
 
void setMessage (const std::string &aMsg)
 
const char * getMessage () const
 
virtual void print (std::ostream &aOut) const
 
const char * what () const noexcept override
 

Protected Member Functions

void addMessage (const std::string &msg)
 

Detailed Description

A class for basic exception functionality.

Exception class manages the concatenation of error messages from all the derived classes. When creating new exceptions, remember to call addMessage() as shown above if the exception class does have any error message.

Constructor & Destructor Documentation

◆ Exception()

SPH::Exception::Exception ( const std::string &  aMsg = "",
const std::string &  aFile = "",
int  aLine = -1 
)

Default Constructor.

This constructor is for backward compatibility. Use the constructor taking file, line, func.

◆ ~Exception()

virtual SPH::Exception::~Exception ( )
throw (
)
inlinevirtual

@ brief Destructor.

Member Function Documentation

◆ addMessage()

void SPH::Exception::addMessage ( const std::string &  msg)
protected

Add to the error message that will be returned for the exception.


The documentation for this class was generated from the following files: