Fork me on GitHub

source: git/external/fastjet/Error.cc@ 66b590f

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 66b590f was d7d2da3, checked in by pavel <pavel@…>, 12 years ago

move branches/ModularDelphes to trunk

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[d7d2da3]1//STARTHEADER
2// $Id$
3//
4// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
5//
6//----------------------------------------------------------------------
7// This file is part of FastJet.
8//
9// FastJet is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; either version 2 of the License, or
12// (at your option) any later version.
13//
14// The algorithms that underlie FastJet have required considerable
15// development and are described in hep-ph/0512210. If you use
16// FastJet as part of work towards a scientific publication, please
17// include a citation to the FastJet paper.
18//
19// FastJet is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22// GNU General Public License for more details.
23//
24// You should have received a copy of the GNU General Public License
25// along with FastJet. If not, see <http://www.gnu.org/licenses/>.
26//----------------------------------------------------------------------
27//ENDHEADER
28
29#include "fastjet/Error.hh"
30#include "fastjet/config.h"
31#include <sstream>
32
33// printing the stack would need execinfo
34#ifdef FASTJET_HAVE_EXECINFO_H
35#include <execinfo.h>
36#include <cstdlib>
37#endif
38
39FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
40
41using namespace std;
42
43bool Error::_print_errors = true;
44bool Error::_print_backtrace = false;
45ostream * Error::_default_ostr = & cerr;
46
47Error::Error(const std::string & message_in) {
48 _message = message_in;
49 if (_print_errors && _default_ostr){
50 ostringstream oss;
51 oss << "fastjet::Error: "<< message_in << endl;
52
53 // only print the stack if execinfo is available and stack enabled
54#ifdef FASTJET_HAVE_EXECINFO_H
55 if (_print_backtrace){
56 void * array[10];
57 char ** messages;
58
59 int size = backtrace(array, 10);
60 messages = backtrace_symbols(array, size);
61
62 oss << "stack:" << endl;
63 for (int i = 1; i < size && messages != NULL; ++i){
64 oss << " #" << i << ": " << messages[i] << endl;
65 }
66 free(messages);
67 }
68#endif
69
70 *_default_ostr << oss.str();
71 // get something written to file even
72 // if the program aborts
73 _default_ostr->flush();
74
75 // // output error message either to cerr or to the user-set stream
76 // if (_default_ostr) { *_default_ostr << oss.str();
77 // // get something written to file even
78 // // if the program aborts
79 // _default_ostr->flush(); }
80 // else { std::cerr << oss.str(); }
81
82 }
83}
84
85FASTJET_END_NAMESPACE
86
Note: See TracBrowser for help on using the repository browser.