Manticore  Version 1.0
Physics of Molecular Clouds
Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | List of all members
mutils::Exception Class Reference

MathUtils exception (base) class. More...

#include <mutils/Exception.h>

Inheritance diagram for mutils::Exception:
Inheritance graph
[legend]
Collaboration diagram for mutils::Exception:
Collaboration graph
[legend]

Public Member Functions

 Exception (int level=Log::ERROR)
 Default constructor. More...
 
virtual ~Exception () noexcept
 Destructor. More...
 
void message (const char *msg)
 Assigns error message. More...
 
void print () const
 Prints error message to log. More...
 
virtual const char * what () const noexcept
 Returns error string. More...
 

Public Attributes

int level
 Condition log level. More...
 

Static Public Attributes

static bool errors = false
 Whether to print error messages (else throw exceptions). More...
 

Protected Attributes

std::string msg_
 Error message. More...
 

Detailed Description

MathUtils exception (base) class.

This class serves as the base for all MathUtils exceptions. In practice, MathUtils code uses this class to propagate error messages for fatal errors. Non-fatal errors should use either a derived sub-class or one of the existing C++ exception types, not this class; alternatively, MU_ERROR_RTN() can be used instead of an exception if a chain of return status values is present.

Author:  Kevin P. Rauch  <rauch.nosp@m.@ast.nosp@m.ro.um.nosp@m.d.ed.nosp@m.u>

Definition at line 146 of file Exception.h.

Constructor & Destructor Documentation

◆ Exception()

mutils::Exception::Exception ( int  level = Log::ERROR)
inline

Default constructor.

Parameters
[in]levelLog level.

Definition at line 151 of file Exception.h.

References message().

◆ ~Exception()

virtual mutils::Exception::~Exception ( )
inlinevirtualnoexcept

Destructor.

Definition at line 155 of file Exception.h.

Member Function Documentation

◆ message()

void mutils::Exception::message ( const char *  msg)
inline

Assigns error message.

Parameters
[in]msgError message.

Definition at line 159 of file Exception.h.

References level, msg_, and mutils::Log::name().

Referenced by Exception().

◆ print()

void mutils::Exception::print ( ) const
inline

Prints error message to log.

Definition at line 166 of file Exception.h.

References level, mutils::Log::level, mutils::Log::stream, and what().

Referenced by mutils::printException().

◆ what()

virtual const char* mutils::Exception::what ( ) const
inlinevirtualnoexcept

Returns error string.

Definition at line 172 of file Exception.h.

References msg_.

Referenced by print().

Member Data Documentation

◆ errors

bool mutils::Exception::errors = false
static

Whether to print error messages (else throw exceptions).

Enabling this results in error messages instead of exceptions being thrown, allowing execution to continue (to the point of catastrophic failure). For diagnostic use only.

Definition at line 182 of file Exception.h.

◆ level

int mutils::Exception::level

Condition log level.

Definition at line 175 of file Exception.h.

Referenced by message(), and print().

◆ msg_

std::string mutils::Exception::msg_
protected

Error message.

Definition at line 186 of file Exception.h.

Referenced by message(), and what().


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