GammaLib  2.0.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLATException.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GLATException.cpp - LAT exception handler *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2011 by Jurgen Knodlseder *
5  * ----------------------------------------------------------------------- *
6  * This program is free software: you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation, either version 3 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program 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 General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18  * *
19  ***************************************************************************/
20 /**
21  * @file GLATException.cpp
22  * @brief LAT exception handler interface implementation.
23  * @author J. Knodlseder
24  */
25 
26 /* __ Includes ___________________________________________________________ */
27 #include "GLATException.hpp"
28 #include "GTools.hpp"
29 
30 
31 /***********************************************************************//**
32  * @brief Exception message.
33  ***************************************************************************/
34 const char* GLATExceptionHandler::what() const throw()
35 {
36  // Set error message
37  std::string message = "*** ERROR in " + m_origin + ": " + m_message;
38 
39  // Return message as C character array
40  return gammalib::tochar(message);
41 }
42 
43 
44 /***********************************************************************//**
45  * @brief Error while opening file.
46  *
47  * @param[in] origin Name of method that has thrown the exception.
48  * @param[in] filename Name of file that could not be opened.
49  * @param[in] message Optional error message.
50  ***************************************************************************/
52  std::string filename,
53  std::string message)
54 {
55  m_origin = origin;
56  m_message = "Unable to open file '"+filename+"'. "+message;
57  return;
58 }
59 
60 
61 /***********************************************************************//**
62  * @brief Member not set.
63  *
64  * @param[in] origin Name of method that has thrown the exception.
65  * @param[in] message Error message.
66  ***************************************************************************/
67 GLATException::no_member::no_member(const std::string& origin,
68  const std::string& message)
69 {
70  // Set origin and message
71  m_origin = origin;
72  m_message = message;
73 
74  // Return
75  return;
76 }
77 
78 
79 /***********************************************************************//**
80  * @brief No sky pixels found.
81  *
82  * @param[in] origin Name of method that has thrown the exception.
83  * @param[in] message Optional error message.
84  ***************************************************************************/
85 GLATException::no_sky::no_sky(std::string origin, std::string message)
86 {
87  m_origin = origin;
88  m_message = "No sky pixels have been found. "+message;
89  return;
90 }
91 
92 
93 /***********************************************************************//**
94  * @brief No energy boundary information found.
95  *
96  * @param[in] origin Name of method that has thrown the exception.
97  * @param[in] message Optional error message.
98  ***************************************************************************/
99 GLATException::no_ebds::no_ebds(std::string origin, std::string message)
100 {
101  m_origin = origin;
102  m_message = "No energy boundaries have been found. "+message;
103  return;
104 }
105 
106 
107 /***********************************************************************//**
108  * @brief No Good Time Intervals found.
109  *
110  * @param[in] origin Name of method that has thrown the exception.
111  * @param[in] message Optional error message.
112  ***************************************************************************/
113 GLATException::no_gti::no_gti(std::string origin, std::string message)
114 {
115  m_origin = origin;
116  m_message = "No Good Time Intervals (GTIs) have been found. "+message;
117  return;
118 }
119 
120 
121 /***********************************************************************//**
122  * @brief No Livetime Cube found.
123  *
124  * @param[in] origin Name of method that has thrown the exception.
125  * @param[in] message Optional error message.
126  ***************************************************************************/
127 GLATException::no_ltcube::no_ltcube(std::string origin, std::string message)
128 {
129  m_origin = origin;
130  m_message = "No Livetime Cube have been found. "+message;
131  return;
132 }
133 
134 
135 /***********************************************************************//**
136  * @brief No energies set
137  *
138  * @param[in] origin Name of method that has thrown the exception.
139  * @param[in] message Optional error message.
140  ***************************************************************************/
141 GLATException::no_energies::no_energies(std::string origin, std::string message)
142 {
143  // Set origin
144  m_origin = origin;
145 
146  // Set message
147  m_message = "Energy vector has not been setup."
148  " Cannot access event information.";
149  if (message.length() > 0)
150  m_message += " "+message;
151 
152  // Return
153  return;
154 }
155 
156 
157 /***********************************************************************//**
158  * @brief No sky directions set
159  *
160  * @param[in] origin Name of method that has thrown the exception.
161  * @param[in] message Optional error message.
162  ***************************************************************************/
163 GLATException::no_dirs::no_dirs(std::string origin, std::string message)
164 {
165  // Set origin
166  m_origin = origin;
167 
168  // Set message
169  m_message = "Sky direction vector has not been setup."
170  " Cannot access event information.";
171  if (message.length() > 0)
172  m_message += " "+message;
173 
174  // Return
175  return;
176 }
177 
178 
179 /***********************************************************************//**
180  * @brief ROI is not a LAT ROI
181  *
182  * @param[in] origin Name of method that has thrown the exception.
183  * @param[in] message Optional error message.
184  ***************************************************************************/
185 GLATException::bad_roi_type::bad_roi_type(std::string origin, std::string message)
186 {
187  // Set origin
188  m_origin = origin;
189 
190  // Set message
191  m_message = "Specified ROI is not of type GLATRoi.";
192  if (message.length() > 0)
193  m_message += " "+message;
194 
195  // Return
196  return;
197 }
198 
199 
200 /***********************************************************************//**
201  * @brief Instrument direction is not a CTA instrument direction
202  *
203  * @param[in] origin Name of method that has thrown the exception.
204  * @param[in] message Optional error message.
205  ***************************************************************************/
207  std::string message)
208 {
209  // Set origin
210  m_origin = origin;
211 
212  // Set message
213  m_message = "Instrument direction is not of type GLATInstDir.";
214  if (message.length() > 0)
215  m_message += " "+message;
216 
217  // Return
218  return;
219 }
220 
221 
222 /***********************************************************************//**
223  * @brief Invalid response found
224  *
225  * @param[in] origin Name of method that has thrown the exception.
226  * @param[in] message Optional error message.
227  ***************************************************************************/
229  std::string message)
230 {
231  m_origin = origin;
232  m_message = "Invalid response encountered. " + message;
233  return;
234 }
235 
236 
237 /***********************************************************************//**
238  * @brief Incompatible source map
239  *
240  * @param[in] origin Name of method that has thrown the exception.
241  * @param[in] name Map name.
242  * @param[in] message Optional error message.
243  ***************************************************************************/
245  std::string name,
246  std::string message)
247 {
248  m_origin = origin;
249  m_message = "Source map \""+name+"\" incompatible with counts map. " +
250  message;
251  return;
252 }
253 
254 
255 /***********************************************************************//**
256  * @brief Diffuse model not found
257  *
258  * @param[in] origin Name of method that has thrown the exception.
259  * @param[in] name Diffuse model.
260  * @param[in] message Optional error message.
261  ***************************************************************************/
263  std::string name,
264  std::string message)
265 {
266  m_origin = origin;
267  m_message = "Diffuse model \""+name+"\" not found. " +
268  message;
269  return;
270 }
271 
272 
273 /***********************************************************************//**
274  * @brief Inconsistent response table
275  *
276  * @param[in] origin Name of method that has thrown the exception.
277  * @param[in] size Size.
278  * @param[in] expect Expected size.
279  * @param[in] message Optional error message.
280  ***************************************************************************/
282  int size,
283  int expect,
284  std::string message)
285 {
286  m_origin = origin;
287  m_message = "Inconsistent response table found. Expected "+gammalib::str(expect)+
288  " elements, found "+gammalib::str(size)+". " + message;
289  return;
290 }
291 
292 
293 /***********************************************************************//**
294  * @brief Response is not a LAT response
295  *
296  * @param[in] origin Name of method that has thrown the exception.
297  * @param[in] message Optional error message.
298  ***************************************************************************/
300  std::string message)
301 {
302  // Set origin
303  m_origin = origin;
304 
305  // Set message
306  m_message = "Response is not of type GLATResponse.";
307  if (message.length() > 0)
308  m_message += " "+message;
309 
310  // Return
311  return;
312 }
no_ebds(std::string origin, std::string message="")
No energy boundary information found.
Gammalib tools definition.
bad_instdir_type(std::string origin, std::string message="")
Instrument direction is not a CTA instrument direction.
no_member(const std::string &origin, const std::string &message)
Member not set.
bad_roi_type(std::string origin, std::string message="")
ROI is not a LAT ROI.
inconsistent_response(std::string origin, int size, int expect, std::string message="")
Inconsistent response table.
char * tochar(const std::string &arg)
Convert string to C string.
Definition: GTools.cpp:699
diffuse_not_found(std::string origin, std::string name, std::string message="")
Diffuse model not found.
LAT exception handler interface definition.
invalid_response(std::string origin, std::string message="")
Invalid response found.
bad_response_type(std::string origin, std::string message="")
Response is not a LAT response.
no_gti(std::string origin, std::string message="")
No Good Time Intervals found.
no_energies(std::string origin, std::string message="")
No energies set.
file_open_error(std::string origin, std::string filename, std::string message="")
Error while opening file.
no_sky(std::string origin, std::string message="")
No sky pixels found.
virtual const char * what() const
Exception message.
no_dirs(std::string origin, std::string message="")
No sky directions set.
wcs_incompatible(std::string origin, std::string name, std::string message="")
Incompatible source map.
no_ltcube(std::string origin, std::string message="")
No Livetime Cube found.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:457