MeteoIODoc  2.10.0
IOExceptions.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-or-later
2 /***********************************************************************************/
3 /* Copyright 2009 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
4 /***********************************************************************************/
5 /* This file is part of MeteoIO.
6  MeteoIO is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser 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  MeteoIO 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 Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef IOEXCEPTIONS_H
20 #define IOEXCEPTIONS_H
21 
22 #include <exception>
23 #include <string>
24 #include <stdlib.h>
25 
26 #define STRINGIFY(x) #x
27 #define TOSTRING(x) STRINGIFY(x)
28 #define AT __FILE__ ":" TOSTRING(__LINE__)
29 
30 namespace mio {
31 
40 class IOException : public std::exception {
41  public:
42  IOException(const std::string& message="IOException occured", const std::string& position="");
43  virtual const char* what() const noexcept override;
44 
45  protected:
46  #if defined(__GLIBC__)
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 
166  public:
167  TimeOutException(const std::string& filename="",
168  const std::string& position="") : IOException("NotFound: " + filename, position){}
169 };
170 } //end namespace
171 
172 #endif
thrown when a there are insufficient rights to access a file/server/... in a certain way (e....
Definition: IOExceptions.h:70
AccessException(const std::string &filename="", const std::string &position="")
Definition: IOExceptions.h:72
thrown when an unsuccessful attempt to convert data types/classes is made (e.g. attempt to convert a ...
Definition: IOExceptions.h:118
ConversionFailedException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:120
The basic exception class adjusted for the needs of SLF software.
Definition: IOExceptions.h:40
IOException(const std::string &message="IOException occured", const std::string &position="")
Definition: IOExceptions.cc:108
std::string msg
Definition: IOExceptions.h:49
std::string full_output
Definition: IOExceptions.h:49
virtual const char * what() const noexcept override
Definition: IOExceptions.cc:142
thrown when an index is out of bounds
Definition: IOExceptions.h:106
IndexOutOfBoundsException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:108
thrown when encountered an unexpected function's argument (e.g. bad index, bad or missing parameter n...
Definition: IOExceptions.h:130
InvalidArgumentException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:132
thrown when parsed data does not reflect an expected format (e.g. premature end of a line,...
Definition: IOExceptions.h:94
InvalidFormatException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:96
thrown when a given filename/servername/... is not valid (e.g. "..", "." or empty)
Definition: IOExceptions.h:82
InvalidNameException(const std::string &filename="", const std::string &position="")
Definition: IOExceptions.h:84
thrown when no data is available
Definition: IOExceptions.h:155
NoDataException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:157
thrown when a there is an unsuccessful attempt to locate a file/server/...
Definition: IOExceptions.h:58
NotFoundException(const std::string &filename="", const std::string &position="")
Definition: IOExceptions.h:60
thrown when an operation does not complete in the foreseen time
Definition: IOExceptions.h:165
TimeOutException(const std::string &filename="", const std::string &position="")
Definition: IOExceptions.h:167
thrown when encountered an unexpected value (e.g. unknown name or key)
Definition: IOExceptions.h:142
UnknownValueException(const std::string &message="", const std::string &position="")
Definition: IOExceptions.h:144
Definition: Config.cc:30