Public Member Functions | Static Public Member Functions

fastjet::Error Class Reference
[Error handling]

base class corresponding to errors that will be thrown by fastjet More...

#include <Error.hh>

Inheritance diagram for fastjet::Error:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Error ()
 default constructors
 Error (const std::string &message)
 ctor from an error message
virtual ~Error ()
 virtual dummy dtor
std::string message () const
 the error ,essage

Static Public Member Functions

static void set_print_errors (bool print_errors)
 controls whether the error message (and the backtrace) is printed out or not
static void set_backtrace (bool enabled)
 controls whether the error message (and the backtrace) is printed out or not

Detailed Description

base class corresponding to errors that will be thrown by fastjet

Definition at line 45 of file Error.hh.


Constructor & Destructor Documentation

fastjet::Error::Error ( const std::string &  message  ) 

ctor from an error message

Parameters:
message to be printed Note: by default, in addition to the error message, the backtrace will be displayed (showing the last few calls before the error)

Definition at line 48 of file Error.cc.

                                      {
  _message = message; 
  if (_print_errors){
    ostringstream oss;
    oss << "fastjet::Error:  "<< message << endl;

    // only print the stack if execinfo is available and stack enabled
#ifdef FASTJET_HAVE_EXECINFO_H
    if (_print_backtrace){
      void * array[10];
      char ** messages;
 
      int size = backtrace(array, 10);
      messages = backtrace_symbols(array, size);
      
      oss << "stack:" << endl;
      for (int i = 1; i < size && messages != NULL; ++i){
        oss << "  #" << i << ": " << messages[i] << endl;
      }
      free(messages);
    }
#endif

    std::cerr << oss.str();
  }
}


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