fuzzylite  6.0
A Fuzzy Logic Control Library in C++
fl::Exception Class Reference

The Exception class is the only type of exception that is utilized throughout the library. More...

#include <Exception.h>

Inheritance diagram for fl::Exception:
Collaboration diagram for fl::Exception:

Public Member Functions

 Exception (const std::string &what)
 
 Exception (const std::string &what, const std::string &file, int line, const std::string &function)
 Constructor to be used in conjunction with macro FL_AT More...
 
virtual ~Exception () FL_INOEXCEPT FL_IOVERRIDE
 
virtual void setWhat (const std::string &what)
 Sets the message of the std::exception More...
 
virtual std::string getWhat () const
 Gets the message of the std::exception More...
 
virtual const char * what () const FL_INOEXCEPT FL_IOVERRIDE
 Gets the message of the std::exception More...
 
virtual void append (const std::string &whatElse)
 Appends a message to the exception. More...
 
virtual void append (const std::string &file, int line, const std::string &function)
 Appends an error trace to the exception. More...
 
virtual void append (const std::string &whatElse, const std::string &file, int line, const std::string &function)
 Appends an error trace with a message to the exception. More...
 

Static Public Member Functions

static std::string btCallStack ()
 Returns the stack trace (if enabled) More...
 
static void signalHandler (int signal)
 Provides a signal handler to catch signals. More...
 
static void convertToException (int signal)
 Converts a given signal into an Exception (does not work very well on Windows) More...
 
static void terminate ()
 Provides a handler for terminate and unexpected signals. More...
 
static void catchException (const std::exception &exception)
 Logs the exception to console and proceeds the regular execution of the library. More...
 

Detailed Description

The Exception class is the only type of exception that is utilized throughout the library.

If the library is built with the compiling flag -DFL_BACKTRACE=ON, the method Exception::btCallStack() will provide a stack trace when an exception is thrown. Please, have in mind that enabling the stack trace requires the external library dbghelp in the Windows platform, which is generally available in the operating system.

Author
Juan Rada-Vilela, Ph.D.
Since
4.0

Definition at line 49 of file Exception.h.

Constructor & Destructor Documentation

◆ Exception() [1/2]

fl::Exception::Exception ( const std::string &  what)
explicit

◆ Exception() [2/2]

fl::Exception::Exception ( const std::string &  what,
const std::string &  file,
int  line,
const std::string &  function 
)
explicit

Constructor to be used in conjunction with macro FL_AT

Parameters
whatis the message of the exception
fileis the name of the file where the exception occurred
lineis the line number in the file where the exception occurred
functionis the name of the function where the exception occurred

◆ ~Exception()

virtual fl::Exception::~Exception ( )
virtual

Member Function Documentation

◆ append() [1/3]

virtual void fl::Exception::append ( const std::string &  whatElse)
virtual

Appends a message to the exception.

Parameters
whatElseis a message to the exception

◆ append() [2/3]

virtual void fl::Exception::append ( const std::string &  file,
int  line,
const std::string &  function 
)
virtual

Appends an error trace to the exception.

The method can be called utilizing the macro FL_AT

Parameters
fileis the name of the file where the exception occurred
lineis the line number in the file where the exception occurred
functionis the name of the function where the exception occurred

◆ append() [3/3]

virtual void fl::Exception::append ( const std::string &  whatElse,
const std::string &  file,
int  line,
const std::string &  function 
)
virtual

Appends an error trace with a message to the exception.

The method can be called utilizing the macro FL_AT

Parameters
whatElseis further information about the exception
fileis the name of the file where the exception occurred
lineis the line number in the file where the exception occurred
functionis the name of the function where the exception occurred

◆ btCallStack()

static std::string fl::Exception::btCallStack ( )
static

Returns the stack trace (if enabled)

Returns
the stack trace (if enabled)

◆ catchException()

static void fl::Exception::catchException ( const std::exception &  exception)
static

Logs the exception to console and proceeds the regular execution of the library.

Parameters
exceptionis the exception thrown

◆ convertToException()

static void fl::Exception::convertToException ( int  signal)
static

Converts a given signal into an Exception (does not work very well on Windows)

Parameters
signalis the code of the signal

◆ getWhat()

virtual std::string fl::Exception::getWhat ( ) const
virtual

Gets the message of the std::exception

Returns
the message of the std::exception

◆ setWhat()

virtual void fl::Exception::setWhat ( const std::string &  what)
virtual

Sets the message of the std::exception

Parameters
whatis the message of the std::exception

◆ signalHandler()

static void fl::Exception::signalHandler ( int  signal)
static

Provides a signal handler to catch signals.

Parameters
signalis the code of the signal

◆ terminate()

static void fl::Exception::terminate ( )
static

Provides a handler for terminate and unexpected signals.

◆ what()

virtual const char* fl::Exception::what ( ) const
virtual

Gets the message of the std::exception

Returns
the message of the std::exception

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