MeteoIODoc  MeteoIODoc-2.9.0
IOExceptions.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2009 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3 /***********************************************************************************/
4 /* This file is part of MeteoIO.
5  MeteoIO is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  MeteoIO is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef IOEXCEPTIONS_H
19 #define IOEXCEPTIONS_H
20 
21 #include <exception>
22 #include <string>
23 #include <stdlib.h>
24 
25 #define STRINGIFY(x) #x
26 #define TOSTRING(x) STRINGIFY(x)
27 #define AT __FILE__ ":" TOSTRING(__LINE__)
28 
29 namespace mio {
30 
39 class IOException : public std::exception {
40  public:
41  IOException(const std::string& message="IOException occured", const std::string& position="");
42  ~IOException() throw() {}
43  virtual const char* what() const throw();
44 
45  protected:
46  #if defined(__linux) && !defined(ANDROID) && !defined(__CYGWIN__)
47  std::string resolveSymbols(char *symbols, const unsigned int& ii, bool& found_main) const;
48  #endif
49  std::string msg, full_output;
50 };
51 
59  public:
60  NotFoundException(const std::string& filename="",
61  const std::string& position="") : IOException("NotFound: " + filename, position){}
62 };
63 
70 class AccessException : public IOException {
71  public:
72  AccessException(const std::string& filename="",
73  const std::string& position="") : IOException("InvalidAccess: " + filename, position){}
74 };
75 
83  public:
84  InvalidNameException(const std::string& filename="",
85  const std::string& position="") : IOException("InvalidName: " + filename, position){}
86 };
87 
95  public:
96  InvalidFormatException(const std::string& message="",
97  const std::string& position="") : IOException("InvalidFormat: " + message, position){}
98 };
99 
107  public:
108  IndexOutOfBoundsException(const std::string& message="",
109  const std::string& position="") : IOException("IndexOutOfBounds: " + message, position){}
110 };
111 
119  public:
120  ConversionFailedException(const std::string& message="",
121  const std::string& position="") : IOException("ConversionFailed: " + message, position){}
122 };
123 
131  public:
132  InvalidArgumentException(const std::string& message="",
133  const std::string& position="") : IOException("InvalidArgument: " + message, position){}
134 };
135 
143  public:
144  UnknownValueException(const std::string& message="",
145  const std::string& position="") : IOException("UnknownValue: " + message, position){}
146 };
147 
155 {
156  public:
157  NoDataException(const std::string& message="",
158  const std::string& position="") : IOException("NoData: " + message, position){}
159 };
160 } //end namespace
161 
162 #endif
NotFoundException(const std::string &filename="", const std::string &position="")
Definition: IOExceptions.h:60
Definition: Config.cc:28
thrown when encountered an unexpected value (e.g. unknown name or key)
Definition: IOExceptions.h:142
AccessException(const std::string &filename="", const std::string &position="")
Definition: IOExceptions.h:72
InvalidArgumentException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:132
virtual const char * what() const
Definition: IOExceptions.cc:140
thrown when a given filename/servername/... is not valid (e.g. "..", "." or empty) ...
Definition: IOExceptions.h:82
~IOException()
Definition: IOExceptions.h:42
InvalidFormatException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:96
IOException(const std::string &message="IOException occured", const std::string &position="")
Definition: IOExceptions.cc:111
UnknownValueException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:144
thrown when no data is available
Definition: IOExceptions.h:154
std::string full_output
Definition: IOExceptions.h:49
std::string msg
Definition: IOExceptions.h:49
thrown when an unsuccessful attempt to convert data types/classes is made (e.g. attempt to convert a ...
Definition: IOExceptions.h:118
thrown when encountered an unexpected function&#39;s argument (e.g. bad index, bad or missing parameter n...
Definition: IOExceptions.h:130
ConversionFailedException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:120
thrown when parsed data does not reflect an expected format (e.g. premature end of a line...
Definition: IOExceptions.h:94
thrown when a there are insufficient rights to access a file/server/... in a certain way (e...
Definition: IOExceptions.h:70
IndexOutOfBoundsException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:108
thrown when an index is out of bounds
Definition: IOExceptions.h:106
InvalidNameException(const std::string &filename="", const std::string &position="")
Definition: IOExceptions.h:84
thrown when a there is an unsuccessful attempt to locate a file/server/...
Definition: IOExceptions.h:58
NoDataException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:157
The basic exception class adjusted for the needs of SLF software.
Definition: IOExceptions.h:39