FairRoot/PandaRoot
GFException.cxx
Go to the documentation of this file.
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #include"GFException.h"
20 
21 bool GFException::fQuiet = false;
22 
23 GFException::GFException(std::string _excString, int _line, std::string _file) : fExcString(_excString), fLine(_line), fFile(_file),fFatal(false) {
24  std::ostringstream ErrMsgStream;
25  ErrMsgStream << "GFException thrown with excString:"
26  << std::endl << fExcString << std::endl
27  << "in line: " << fLine << " in file: " << fFile << std::endl
28  << "with fatal flag " << fFatal << std::endl;
29  fErrorMessage = ErrMsgStream.str();
30 }
31 
33 }
34 
35 void GFException::setNumbers(std::string _numbersLabel,
36  const std::vector<double>& _numbers) {
37  fNumbersLabel = _numbersLabel;
38  fNumbers = _numbers;
39 }
40 
41 void GFException::setMatrices(std::string _matricesLabel,
42  const std::vector< TMatrixT<double> >& _matrices) {
43  fMatricesLabel = _matricesLabel;
44  fMatrices = _matrices;
45 }
46 
47 const char* GFException::what() const throw(){
48  if(fQuiet) return "";
49  return fErrorMessage.c_str();
50 }
51 
53  if(fQuiet) return;
54  if(fNumbers.size() == 0 && fMatrices.size() == 0) return;//do nothing
55  std::cout << "GFException Info Output" << std::endl;
56  std::cout << "===========================" << std::endl;
57  if(fNumbersLabel != "") {
58  std::cout << "Numbers Label String:" << std::endl;
59  std::cout << fNumbersLabel << std::endl;
60  }
61  if(fNumbers.size() > 0) {
62  std::cout << "---------------------------" << std::endl;
63  std::cout << "Numbers:" << std::endl;
64  for(unsigned int i=0;i<fNumbers.size(); i++ ) std::cout << fNumbers.at(i) << std::endl;
65  }
66  if(fMatricesLabel != "") {
67  std::cout << "---------------------------" << std::endl;
68  std::cout << "Matrices Label String:" << std::endl;
69  std::cout << fMatricesLabel << std::endl;
70  }
71  if(fMatrices.size() > 0) {
72  std::cout << "---------------------------" << std::endl;
73  std::cout << "Matrices:" << std::endl;
74  for(unsigned int i=0;i<fMatrices.size(); i++ ) fMatrices.at(i).Print();
75  }
76  std::cout << "===========================" << std::endl;
77 }
std::string fNumbersLabel
Definition: GFException.h:57
Int_t i
Definition: run_full.C:25
virtual const char * what() const
standard error message handling for exceptions. use like &quot;std::cerr &lt;&lt; e.what();&quot; ...
Definition: GFException.cxx:47
std::string fMatricesLabel
Definition: GFException.h:58
std::vector< TMatrixT< double > > fMatrices
Definition: GFException.h:60
void setNumbers(std::string, const std::vector< double > &)
set list of numbers with description
Definition: GFException.cxx:35
std::string fErrorMessage
Definition: GFException.h:55
void setMatrices(std::string, const std::vector< TMatrixT< double > > &)
set list of matrices with description
Definition: GFException.cxx:41
std::string fFile
Definition: GFException.h:53
void info()
print information in the exception object
Definition: GFException.cxx:52
GFException(std::string, int, std::string)
Initializing constructor.
Definition: GFException.cxx:23
std::vector< double > fNumbers
Definition: GFException.h:59
virtual ~GFException()
Definition: GFException.cxx:32
std::string fExcString
Definition: GFException.h:51
static bool fQuiet
Definition: GFException.h:49