GammaLib 2.0.0
Loading...
Searching...
No Matches
GException.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GException.hpp - Exception handler *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2006-2021 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file GException.hpp
23 * @brief Exception handler interface definition.
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GEXCEPTION_HPP
28#define GEXCEPTION_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string> // string
32#include <stdexcept> // exception
33
34/* __ Forward declarations ______________________________________________ */
35class GEnergy;
36
37/* __ Prototypes ________________________________________________________ */
38namespace gammalib {
39 void check_energy_interval(const std::string& origin,
40 const GEnergy& emin,
41 const GEnergy& emax);
42 void check_prj_x2s_status(const std::string& origin,
43 const int& status,
44 const int& number);
45 void check_prj_s2x_status(const std::string& origin,
46 const int& status,
47 const int& number);
48}
49
50
51/***********************************************************************//**
52 * @class GExceptionHandler
53 *
54 * @brief Interface for exception handler.
55 ***************************************************************************/
56class GExceptionHandler : public std::exception {
57public:
59 virtual ~GExceptionHandler() throw() { }
60 virtual const char* what() const throw();
61protected:
62 std::string m_origin;
63 std::string m_message;
64};
65
66
67/***********************************************************************//**
68 * @class GException
69 *
70 * @brief Interface for exceptions
71 *
72 * The exception class is the master class that is thrown in case of
73 * exceptions.
74 ***************************************************************************/
76public:
77
78 // --- LOGIC EXCEPTIONS (what client could have tested) ---
79
80 // Invalid value
82 public:
83 invalid_value(const std::string& origin,
84 const std::string& message);
85 };
86
87 // Invalid argument
89 public:
90 invalid_argument(const std::string& origin,
91 const std::string& message);
92 invalid_argument(const std::string& origin,
93 const std::string& argument,
94 const std::string& message);
95 };
96
97 // Invalid return value
99 public:
100 invalid_return_value(const std::string& origin,
101 const std::string& message);
102 };
103
104 // Out of range
106 public:
107 out_of_range(const std::string& origin,
108 const std::string& what,
109 const int& index,
110 const int& elements,
111 const std::string& message = "");
112 };
113
114 // FITS error
116 public:
117 fits_error(const std::string& origin,
118 const int& status,
119 const std::string& message = "");
120 };
121
122
123 // --- RUNTIME EXCEPTIONS (not testable by client) ---
124
125 // Runtime error
127 public:
128 runtime_error(const std::string& origin,
129 const std::string& message = "");
130 };
131
132 //underflow_error
133
134 //overflow_error
135
136 // File error
138 public:
139 file_error(const std::string& origin,
140 const std::string& message = "");
141 };
142
143 // Feature not implemented
145 public:
146 feature_not_implemented(const std::string& origin,
147 const std::string& message = "");
148 };
149
150
151 // --- TEST EXCEPTIONS (only used by test suite) ---
152
153 // Signal nested try
155 public:
156 test_nested_try_error(const std::string& origin,
157 const std::string& message = "");
158 };
159
160 // Signal test failure
162 public:
163 test_failure(const std::string& origin,
164 const std::string& message = "");
165 };
166
167 // Signal test error
169 public:
170 test_error(const std::string& origin,
171 const std::string& message = "");
172 };
173
174};
175
176#endif /* GEXCEPTION_HPP */
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Interface for exception handler.
virtual const char * what() const
Exception message.
virtual ~GExceptionHandler()
std::string m_message
std::string m_origin
Interface for exceptions.
void check_energy_interval(const std::string &origin, const GEnergy &emin, const GEnergy &emax)
Checks energy interval.
std::string number(const std::string &noun, const int &number)
Convert singular noun into number noun.
Definition GTools.cpp:1167
void check_prj_s2x_status(const std::string &origin, const int &status, const int &number)
Checks status of GWcs::prj_s2x method.
void check_prj_x2s_status(const std::string &origin, const int &status, const int &number)
Checks status of GWcs::prj_x2s method.