SND@LHC Software
Loading...
Searching...
No Matches
genfit::Exception Class Reference

Exception class for error handling in GENFIT (provides storage for diagnostic information) More...

#include <Exception.h>

Inheritance diagram for genfit::Exception:
Collaboration diagram for genfit::Exception:

Public Member Functions

 Exception (std::string excString, int line, std::string file)
 Initializing constructor.
 
virtual ~Exception () throw ()
 
void setFatal (bool b=true)
 Set fatal flag.
 
bool isFatal ()
 Get fatal flag.
 
void setNumbers (std::string, const std::vector< double > &)
 Set list of numbers with description.
 
void setMatrices (std::string, const std::vector< TMatrixD > &)
 Set list of matrices with description.
 
void info ()
 Print information in the exception object.
 
virtual const char * what () const throw ()
 Standard error message handling for exceptions. use like "std::cerr << e.what();".
 
std::string getExcString ()
 

Static Public Member Functions

static void quiet (bool b=true)
 "std::cerr << e.what();" will not write anything.
 

Private Attributes

std::string excString_
 
int line_
 
std::string file_
 
std::string errorMessage_
 
std::string numbersLabel_
 
std::string matricesLabel_
 
std::vector< double > numbers_
 
std::vector< TMatrixD > matrices_
 
bool fatal_
 

Static Private Attributes

static bool quiet_ = true
 

Detailed Description

Exception class for error handling in GENFIT (provides storage for diagnostic information)

Author
Christian Höppner (Technische Universität München, original author)
Sebastian Neubert (Technische Universität München, original author)

This is the class that is used for all error handling in GENFIT. It is a utility class that allows to store numbers and matrices together with an error string. The exception class can then be thrown when an error is detected and the C++ exception handling facilities can be used to catch and process the exception.

Definition at line 48 of file Exception.h.

Constructor & Destructor Documentation

◆ Exception()

genfit::Exception::Exception ( std::string  excString,
int  line,
std::string  file 
)

Initializing constructor.

Parameters
excStringerror message.
lineline at which the exception is created. Can be set through LINE macro.
filesourcefile in which the exception is created. Can be set through FILE macro.

Definition at line 26 of file Exception.cc.

26 :
27 excString_(excString), line_(line), file_(file), fatal_(false) {
28 std::ostringstream ErrMsgStream;
29 ErrMsgStream << "genfit::Exception thrown with excString:"
30 << std::endl << excString_ << std::endl
31 << "in line: " << line_ << " in file: " << file_ << std::endl
32 << "with fatal flag " << fatal_ << std::endl;
33 errorMessage_ = ErrMsgStream.str();
34}
std::string errorMessage_
Definition Exception.h:88
std::string file_
Definition Exception.h:86
std::string excString_
Definition Exception.h:84

◆ ~Exception()

genfit::Exception::~Exception ( )
throw (
)
virtual

Definition at line 36 of file Exception.cc.

36 {
37}

Member Function Documentation

◆ getExcString()

std::string genfit::Exception::getExcString ( )
inline

Definition at line 75 of file Exception.h.

75{return excString_;}

◆ info()

void genfit::Exception::info ( )

Print information in the exception object.

Definition at line 59 of file Exception.cc.

59 {
60 if(quiet_) return;
61 if(numbers_.empty() && matrices_.empty()) return; //do nothing
62 std::cout << "genfit::Exception Info Output" << std::endl;
63 std::cout << "===========================" << std::endl;
64 if(numbersLabel_ != "") {
65 std::cout << "Numbers Label String:" << std::endl;
66 std::cout << numbersLabel_ << std::endl;
67 }
68 if(!numbers_.empty()) {
69 std::cout << "---------------------------" << std::endl;
70 std::cout << "Numbers:" << std::endl;
71 for(unsigned int i=0;i<numbers_.size(); ++i ) std::cout << numbers_[i] << std::endl;
72 }
73 if(matricesLabel_ != "") {
74 std::cout << "---------------------------" << std::endl;
75 std::cout << "Matrices Label String:" << std::endl;
76 std::cout << matricesLabel_ << std::endl;
77 }
78 if(!matrices_.empty()) {
79 std::cout << "---------------------------" << std::endl;
80 std::cout << "Matrices:" << std::endl;
81 for(unsigned int i=0;i<matrices_.size(); ++i ) matrices_[i].Print();
82 }
83 std::cout << "===========================" << std::endl;
84}
std::vector< TMatrixD > matrices_
Definition Exception.h:93
std::string matricesLabel_
Definition Exception.h:91
static bool quiet_
Definition Exception.h:82
std::vector< double > numbers_
Definition Exception.h:92
std::string numbersLabel_
Definition Exception.h:90
int i
Definition ShipAna.py:86

◆ isFatal()

bool genfit::Exception::isFatal ( )
inline

Get fatal flag.

Definition at line 63 of file Exception.h.

63{return fatal_;}

◆ quiet()

static void genfit::Exception::quiet ( bool  b = true)
inlinestatic

"std::cerr << e.what();" will not write anything.

Definition at line 78 of file Exception.h.

◆ setFatal()

void genfit::Exception::setFatal ( bool  b = true)
inline

Set fatal flag.

Definition at line 61 of file Exception.h.

61{fatal_=b;}

◆ setMatrices()

void genfit::Exception::setMatrices ( std::string  _matricesLabel,
const std::vector< TMatrixD > &  _matrices 
)

Set list of matrices with description.

Definition at line 45 of file Exception.cc.

46 {
47 matricesLabel_ = _matricesLabel;
48 matrices_ = _matrices;
49}

◆ setNumbers()

void genfit::Exception::setNumbers ( std::string  _numbersLabel,
const std::vector< double > &  _numbers 
)

Set list of numbers with description.

Definition at line 39 of file Exception.cc.

40 {
41 numbersLabel_ = _numbersLabel;
42 numbers_ = _numbers;
43}

◆ what()

const char * genfit::Exception::what ( ) const
throw (
)
virtual

Standard error message handling for exceptions. use like "std::cerr << e.what();".

Definition at line 51 of file Exception.cc.

51 {
52 //std::cerr << errorMessage_.c_str() << std::endl; // FIXME just for debugging purposes
53 if(quiet_) {
54 return "";
55 }
56 return errorMessage_.c_str();
57}

Member Data Documentation

◆ errorMessage_

std::string genfit::Exception::errorMessage_
private

Definition at line 88 of file Exception.h.

◆ excString_

std::string genfit::Exception::excString_
private

Definition at line 84 of file Exception.h.

◆ fatal_

bool genfit::Exception::fatal_
private

Definition at line 95 of file Exception.h.

◆ file_

std::string genfit::Exception::file_
private

Definition at line 86 of file Exception.h.

◆ line_

int genfit::Exception::line_
private

Definition at line 85 of file Exception.h.

◆ matrices_

std::vector<TMatrixD> genfit::Exception::matrices_
private

Definition at line 93 of file Exception.h.

◆ matricesLabel_

std::string genfit::Exception::matricesLabel_
private

Definition at line 91 of file Exception.h.

◆ numbers_

std::vector<double> genfit::Exception::numbers_
private

Definition at line 92 of file Exception.h.

◆ numbersLabel_

std::string genfit::Exception::numbersLabel_
private

Definition at line 90 of file Exception.h.

◆ quiet_

bool genfit::Exception::quiet_ = true
staticprivate

Definition at line 82 of file Exception.h.


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