Exception Class Reference

Exception class implementing a stacktrace function. More...

#include <Exception>

Inherits std::exception.


Public Member Functions

 Exception (std::string msg)
 Constructor awaiting your error message as a std::string.
 Exception (const char *msg)
 Constructor specially for using standard exception handling like bad_alloc or similiar.
virtual ~Exception () throw ()
 Virtual standard destructor who must be disallowed to throw exceptions.
virtual std::string getError (void) const throw ()
 Returning the last error message and itself is disallowed to throw a exception.
virtual const char * what (void) const throw ()
 Polymorphed what function from standard C++ exception class retunring the last error message and itself is disallowed to throw a exception.
void printStacktrace (void) const throw ()
 Printing out a stacktrace and itself is disallowed to throw a exception.


Detailed Description

Exception class implementing a stacktrace function.

Author:
Markus Mazurczak
Version:
1.0
Date:
2010

Definition at line 80 of file Exception.


Constructor & Destructor Documentation

Exception::Exception ( std::string  msg  ) 

Constructor awaiting your error message as a std::string.

Parameters:
msg Error description
Todo:
Implementing option to specify maximal stacktracing depth

Definition at line 3 of file Exception.cpp.

00003                                   {
00004     _msg = msg;
00005     _traced = backtrace(_stacktrace, 64);
00006 }

Exception::Exception ( const char *  msg  ) 

Constructor specially for using standard exception handling like bad_alloc or similiar.

Parameters:
*msg Char pointer pointing to the error description
Todo:
Implementing option to specify maximal stacktracing depth

Definition at line 8 of file Exception.cpp.

00008                                     {
00009     _msg = msg;
00010     _traced = backtrace(_stacktrace, 64);
00011 }

Exception::~Exception (  )  throw () [inline, virtual]

Virtual standard destructor who must be disallowed to throw exceptions.

Definition at line 101 of file Exception.

00101 {};


Member Function Documentation

std::string Exception::getError ( void   )  const throw () [virtual]

Returning the last error message and itself is disallowed to throw a exception.

Returns:
std::string

Definition at line 101 of file Exception.

void Exception::printStacktrace ( void   )  const throw ()

Printing out a stacktrace and itself is disallowed to throw a exception.

Definition at line 21 of file Exception.cpp.

00021                                               {
00022     Dl_info dlinfo;
00023     const char *symname;
00024     char *demangled;
00025     int status;
00026 
00027     if(!_traced) {
00028         std::cerr << "Error: No stacktrace available" << std::endl;
00029     } else {
00030         for(int i = 0; i < (_traced - 1); i++) {
00031             if(!dladdr(_stacktrace[i], &dlinfo)) {
00032                 continue;
00033             }
00034             symname = dlinfo.dli_sname;
00035             demangled = abi::__cxa_demangle(symname, NULL, 0, &status);
00036             if(status == 0 && demangled) {
00037                 symname = demangled;
00038             }
00039             std::cerr << dlinfo.dli_fname << " -- " << symname << std::endl;
00040             if(demangled) {
00041                 free(demangled);
00042             }
00043         }
00044     }
00045 }

const char * Exception::what ( void   )  const throw () [virtual]

Polymorphed what function from standard C++ exception class retunring the last error message and itself is disallowed to throw a exception.

Returns:
const char *

Definition at line 17 of file Exception.cpp.

00017                                           {
00018     return(_msg.c_str());
00019 }


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

Generated on Sat Feb 6 20:35:37 2010 for Exception by  doxygen 1.5.8