GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GMWLException.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GMWLException.hpp - Multi-wavelength exception handler *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2011 by Jurgen Knodlseder *
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 GMWLException.hpp
23  * @brief MWL exception handler interface definition.
24  * @author J. Knodlseder
25  */
26 
27 #ifndef GMWLEXCEPTION_HPP
28 #define GMWLEXCEPTION_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string> // string
32 #include <sstream> // ostringstream
33 #include <stdexcept> // exception
34 
35 
36 /***********************************************************************//**
37  * @class GMWLExceptionHandler
38  *
39  * @brief Interface for multi-wavelength exception handler
40  ***************************************************************************/
41 class GMWLExceptionHandler : public std::exception {
42 public:
44  virtual ~GMWLExceptionHandler(void) throw() { }
45  virtual const char* what() const throw();
46 protected:
47  std::string m_origin;
48  std::string m_message;
49 };
50 
51 
52 /***********************************************************************//**
53  * @class GMWLException
54  *
55  * @brief Interface for multi-wavelength exceptions
56  *
57  * This object is thrown in case of a multi-wavelength exception.
58  ***************************************************************************/
60 public:
61  // General exceptions
62  class file_open_error : public GMWLExceptionHandler {
63  public:
64  file_open_error(std::string origin, std::string filename,
65  std::string message = "");
66  };
67  class bad_file_format : public GMWLExceptionHandler {
68  public:
69  bad_file_format(std::string origin, std::string message = "");
70  };
71  class invalid_unit : public GMWLExceptionHandler {
72  public:
73  invalid_unit(std::string origin, std::string unit,
74  std::string message = "");
75  };
76 
77  // Observation exceptions
78  class bad_response_type : public GMWLExceptionHandler {
79  public:
80  bad_response_type(std::string origin, std::string message = "");
81  };
82 };
83 
84 #endif /* GMWLEXCEPTION_HPP */
virtual const char * what() const
Exception message.
Interface for multi-wavelength exception handler.
Interface for multi-wavelength exceptions.
virtual ~GMWLExceptionHandler(void)