Fork me on GitHub

source: git/external/fastjet/Error.hh@ a52e99e

Last change on this file since a52e99e was cb80e6f, checked in by Pavel Demin <pavel.demin@…>, 4 years ago

update FastJet library to 3.3.4 and FastJet Contrib library to 1.045

  • Property mode set to 100644
File size: 4.3 KB
Line 
1#ifndef __FASTJET_ERROR_HH__
2#define __FASTJET_ERROR_HH__
3
4//FJSTARTHEADER
5// $Id: Error.hh 4442 2020-05-05 07:50:11Z soyez $
6//
7// Copyright (c) 2005-2020, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
8//
9//----------------------------------------------------------------------
10// This file is part of FastJet.
11//
12// FastJet is free software; you can redistribute it and/or modify
13// it under the terms of the GNU General Public License as published by
14// the Free Software Foundation; either version 2 of the License, or
15// (at your option) any later version.
16//
17// The algorithms that underlie FastJet have required considerable
18// development. They are described in the original FastJet paper,
19// hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
20// FastJet as part of work towards a scientific publication, please
21// quote the version you use and include a citation to the manual and
22// optionally also to hep-ph/0512210.
23//
24// FastJet is distributed in the hope that it will be useful,
25// but WITHOUT ANY WARRANTY; without even the implied warranty of
26// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27// GNU General Public License for more details.
28//
29// You should have received a copy of the GNU General Public License
30// along with FastJet. If not, see <http://www.gnu.org/licenses/>.
31//----------------------------------------------------------------------
32//FJENDHEADER
33
34#include<iostream>
35#include<string>
36#include "fastjet/internal/base.hh"
37#include "fastjet/config.h"
38#if (!defined(FASTJET_HAVE_EXECINFO_H)) || defined(__FJCORE__)
39#include "fastjet/LimitedWarning.hh"
40#endif
41
42FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
43
44/// @ingroup error_handling
45/// \class Error
46/// base class corresponding to errors that can be thrown by FastJet
47class Error {
48public:
49 /// default constructors
50 Error() {}
51
52 /// ctor from an error message
53 /// \param message to be printed
54 /// Note: in addition to the error message, one can choose to print the
55 /// backtrace (showing the last few calls before the error) by
56 /// using set_print_backtrace(true). The default is "false".
57 Error(const std::string & message);
58
59 /// virtual dummy dtor
60 virtual ~Error() {}
61
62 /// the error message
63 std::string message() const {return _message;}
64
65 /// an alternative access to the error message (more standard)
66 std::string description() const {return message();}
67
68 /// controls whether the error message (and the backtrace, if its printing is enabled)
69 /// is printed out or not
70 static void set_print_errors(bool print_errors) {_print_errors = print_errors;}
71
72 /// controls whether the backtrace is printed out with the error message or not.
73 /// The default is "false".
74 static void set_print_backtrace(bool enabled);
75
76 /// sets the default output stream for all errors; by default
77 /// cerr; if it's null then error output is suppressed.
78 static void set_default_stream(std::ostream * ostr) {
79 _default_ostr = ostr;
80 }
81
82private:
83
84#ifndef __FJCORE__
85#if defined(FASTJET_HAVE_EXECINFO_H) && defined(FASTJET_HAVE_DEMANGLING_SUPPORT)
86 /// demangle a given backtrace symbol
87 std::string _demangle(const char* symbol);
88#endif
89#endif
90
91 std::string _message; ///< error message
92 static bool _print_errors; ///< do we print anything?
93 static bool _print_backtrace; ///< do we print the backtrace?
94 static std::ostream * _default_ostr; ///< the output stream (cerr if not set)
95#if (!defined(FASTJET_HAVE_EXECINFO_H)) || defined(__FJCORE__)
96 static LimitedWarning _execinfo_undefined;
97#endif
98};
99
100
101/// @ingroup error_handling
102/// \class InternalError
103/// class corresponding to critical internal errors
104///
105/// This is an error class (derived from Error) meant for serious,
106/// critical, internal errors that we still want to be catchable by an
107/// end-user [e.g. a serious issue in clustering where the end-user
108/// can catch it and retry with a different strategy]
109///
110/// Please directly contact the FastJet authors if you see such an
111/// error.
112class InternalError : public Error{
113public:
114 /// ctor with error message:
115 /// just add a bit of info to the message and pass it to the base class
116 InternalError(const std::string & message_in) : Error(std::string("*** CRITICAL INTERNAL FASTJET ERROR *** CONTACT THE AUTHORS *** ") + message_in){ }
117};
118
119FASTJET_END_NAMESPACE
120
121#endif // __FASTJET_ERROR_HH__
Note: See TracBrowser for help on using the repository browser.