1 | #ifndef __FASTJET_ERROR_HH__
|
---|
2 | #define __FASTJET_ERROR_HH__
|
---|
3 |
|
---|
4 | //FJSTARTHEADER
|
---|
5 | // $Id: Error.hh 3433 2014-07-23 08:17:03Z salam $
|
---|
6 | //
|
---|
7 | // Copyright (c) 2005-2014, 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 |
|
---|
38 | FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
|
---|
39 |
|
---|
40 | /// @ingroup error_handling
|
---|
41 | /// \class Error
|
---|
42 | /// base class corresponding to errors that can be thrown by FastJet
|
---|
43 | class Error {
|
---|
44 | public:
|
---|
45 | /// default constructors
|
---|
46 | Error() {}
|
---|
47 |
|
---|
48 | /// ctor from an error message
|
---|
49 | /// \param message to be printed
|
---|
50 | /// Note: in addition to the error message, one can choose to print the
|
---|
51 | /// backtrace (showing the last few calls before the error) by
|
---|
52 | /// using set_print_backtrace(true). The default is "false".
|
---|
53 | Error(const std::string & message);
|
---|
54 |
|
---|
55 | /// virtual dummy dtor
|
---|
56 | virtual ~Error() {}
|
---|
57 |
|
---|
58 | /// the error message
|
---|
59 | std::string message() const {return _message;}
|
---|
60 |
|
---|
61 | /// controls whether the error message (and the backtrace, if its printing is enabled)
|
---|
62 | /// is printed out or not
|
---|
63 | static void set_print_errors(bool print_errors) {_print_errors = print_errors;}
|
---|
64 |
|
---|
65 | /// controls whether the backtrace is printed out with the error message or not.
|
---|
66 | /// The default is "false".
|
---|
67 | static void set_print_backtrace(bool enabled) {_print_backtrace = enabled;}
|
---|
68 |
|
---|
69 | /// sets the default output stream for all errors; by default
|
---|
70 | /// cerr; if it's null then error output is suppressed.
|
---|
71 | static void set_default_stream(std::ostream * ostr) {
|
---|
72 | _default_ostr = ostr;
|
---|
73 | }
|
---|
74 |
|
---|
75 | private:
|
---|
76 | std::string _message; ///< error message
|
---|
77 | static bool _print_errors; ///< do we print anything?
|
---|
78 | static bool _print_backtrace; ///< do we print the backtrace?
|
---|
79 | static std::ostream * _default_ostr; ///< the output stream (cerr if not set)
|
---|
80 | };
|
---|
81 |
|
---|
82 |
|
---|
83 | FASTJET_END_NAMESPACE
|
---|
84 |
|
---|
85 | #endif // __FASTJET_ERROR_HH__
|
---|