cartobase 6.0.6
ioexcept.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34#ifndef CARTOBASE_EXCEPTION_IOEXCEPT_H
35#define CARTOBASE_EXCEPTION_IOEXCEPT_H
36
38#include <stdexcept>
39#include <string>
40
41namespace carto
42{
43
45 class io_error : public std::runtime_error
46 {
47 public:
48 io_error( const std::string & arg, const std::string & filename = "" );
49 virtual ~io_error() throw();
50 virtual const char* what() const throw();
51 std::string filename() const { return _filename; }
52
53 static void launchErrnoExcept( const std::string & filename = "" );
54 static void keepExceptionPriority( std::exception & e, int & prio,
55 int & type, std::string & message,
56 int raiseprio = 0 );
57 static void launchExcept( int code, const std::string & msg,
58 const std::string & defmsg = "" );
61 static void checkFatalIOErrno( const std::string & filename = "" );
62
63 private:
64 std::string _filename;
65 mutable std::string _formed_msg;
66 };
67
68
70 class open_error : public io_error
71 {
72 public:
73 open_error( const std::string & arg, const std::string & filename = "" );
74 virtual ~open_error() throw();
75 };
76
77
81 {
82 public:
83 file_not_found_error( const std::string & arg,
84 const std::string & filename );
85 file_not_found_error( const std::string & filename = "" );
86 virtual ~file_not_found_error() throw();
87 };
88
89
92 {
93 public:
94 permission_error( const std::string & arg, const std::string & filename );
95 permission_error( const std::string & filename = "" );
96 virtual ~permission_error() throw();
97 };
98
99
102 {
103 public:
104 is_dir_error( const std::string & arg, const std::string & filename );
105 is_dir_error( const std::string & filename = "" );
106 virtual ~is_dir_error() throw();
107 };
108
109
113 {
114 public:
115 no_dir_error( const std::string & arg, const std::string & filename );
116 no_dir_error( const std::string & filename = "" );
117 virtual ~no_dir_error() throw();
118 };
119
120
123 {
124 public:
125 too_many_descriptors_error( const std::string & arg,
126 const std::string & filename );
127 too_many_descriptors_error( const std::string & filename = "" );
129 };
130
131
135 {
136 public:
137 read_write_error( const std::string & arg,
138 const std::string & filename = "" );
139 virtual ~read_write_error() throw();
140 };
141
142
145 {
146 public:
147 bad_medium_error( const std::string & arg, const std::string & filename );
148 bad_medium_error( const std::string & filename = "" );
149 virtual ~bad_medium_error() throw();
150 };
151
152
155 {
156 public:
157 disk_full_error( const std::string & arg, const std::string & filename );
158 disk_full_error( const std::string & filename = "" );
159 virtual ~disk_full_error() throw();
160 };
161
162
165 {
166 public:
167 quota_exceeded_error( const std::string & arg,
168 const std::string & filename );
169 quota_exceeded_error( const std::string & filename = "" );
170 virtual ~quota_exceeded_error() throw();
171 };
172
173
176 {
177 public:
178 stream_state_error( const std::string & arg,
179 const std::string & filename = "" );
180 virtual ~stream_state_error() throw();
181 };
182
183
186 {
187 public:
188 eof_error( const std::string & arg, const std::string & filename );
189 eof_error( const std::string & filename = "" );
190 virtual ~eof_error() throw();
191 };
192
193
196 {
197 public:
198 not_open_error( const std::string & arg, const std::string & filename );
199 not_open_error( const std::string & filename = "" );
200 virtual ~not_open_error() throw();
201 };
202
203
206 {
207 public:
208 stream_fail_error( const std::string & arg, const std::string & filename );
209 stream_fail_error( const std::string & filename = "" );
210 virtual ~stream_fail_error() throw();
211 };
212
213
215 class format_error : public io_error
216 {
217 public:
218 format_error( const std::string & arg, const std::string & filename );
219 format_error( const std::string & filename = "" );
220 virtual ~format_error() throw();
221 };
222
223
226 {
227 public:
228 wrong_format_error( const std::string & arg,
229 const std::string & filename );
230 wrong_format_error( const std::string & filename = "" );
231 virtual ~wrong_format_error() throw();
232 };
233
234
237 {
238 public:
239 format_mismatch_error( const std::string & arg,
240 const std::string & filename );
241 format_mismatch_error( const std::string & filename = "" );
242 virtual ~format_mismatch_error() throw();
243 };
244
245
248 {
249 public:
250 corrupt_stream_error( const std::string & arg,
251 const std::string & filename );
252 corrupt_stream_error( const std::string & filename = "" );
253 virtual ~corrupt_stream_error() throw();
254 };
255
256
260 {
261 public:
262 invalid_format_error( const std::string & arg,
263 const std::string & filename );
264 invalid_format_error( const std::string & filename = "" );
265 virtual ~invalid_format_error() throw();
266 };
267
268
272 {
273 public:
274 datatype_format_error( const std::string & arg,
275 const std::string & filename );
276 datatype_format_error( const std::string & filename = "" );
277 virtual ~datatype_format_error() throw();
278 };
279
280
283 {
284 public:
291 parse_error( const std::string& what_arg,
292 const std::string& token_arg,
293 const std::string& filename_arg,
294 int line_arg );
300 parse_error( const std::string& what_arg,
301 const std::string& token_arg,
302 int line_arg );
303 /* DO NOT USE! DEPRECIATED
304 @param what_arg not used
305 @param line_arg number of the line in the file
306 @param filename_arg name of the file
307 */
308 parse_error( const std::string& what_arg, int line_arg,
309 const std::string& filename_arg = std::string() )
311
312 virtual ~parse_error() throw ();
313
314 int line() const;
315
316 private:
317 static std::string init( const std::string& what_arg,
318 const std::string& token_arg,
319 const std::string& filename_arg,
320 int line_arg );
321 static std::string init( const std::string& what_arg,
322 const std::string& token_arg,
323 int line_arg );
324
325 const std::string _filename;
326 const int _line;
327 };
328
329
331 {
332 public:
333 syntax_check_error( const std::string & arg,
334 const std::string & filename );
335 syntax_check_error( const std::string & filename = "" );
336 virtual ~syntax_check_error() throw();
337 };
338
339}
340
341#endif
342
343
#define __deprecated__(msg)
#define __attribute__(a)
bad_medium_error(const std::string &filename="")
bad_medium_error(const std::string &arg, const std::string &filename)
corrupt_stream_error(const std::string &filename="")
corrupt_stream_error(const std::string &arg, const std::string &filename)
datatype_format_error(const std::string &filename="")
datatype_format_error(const std::string &arg, const std::string &filename)
disk_full_error(const std::string &filename="")
disk_full_error(const std::string &arg, const std::string &filename)
virtual ~eof_error()
eof_error(const std::string &filename="")
eof_error(const std::string &arg, const std::string &filename)
file_not_found_error(const std::string &filename="")
file_not_found_error(const std::string &arg, const std::string &filename)
format_error(const std::string &arg, const std::string &filename)
format_error(const std::string &filename="")
virtual ~format_error()
format_mismatch_error(const std::string &filename="")
format_mismatch_error(const std::string &arg, const std::string &filename)
invalid_format_error(const std::string &arg, const std::string &filename)
invalid_format_error(const std::string &filename="")
static void keepExceptionPriority(std::exception &e, int &prio, int &type, std::string &message, int raiseprio=0)
virtual ~io_error()
static void checkFatalIOErrno(const std::string &filename="")
checks if errno is a disk full, access or quota error, then throw an exception if so.
static void launchErrnoExcept(const std::string &filename="")
static void launchExcept(int code, const std::string &msg, const std::string &defmsg="")
virtual const char * what() const
std::string filename() const
Definition ioexcept.h:51
io_error(const std::string &arg, const std::string &filename="")
is_dir_error(const std::string &filename="")
is_dir_error(const std::string &arg, const std::string &filename)
virtual ~is_dir_error()
no_dir_error(const std::string &filename="")
virtual ~no_dir_error()
no_dir_error(const std::string &arg, const std::string &filename)
not_open_error(const std::string &arg, const std::string &filename)
not_open_error(const std::string &filename="")
virtual ~open_error()
open_error(const std::string &arg, const std::string &filename="")
parse_error(const std::string &what_arg, int line_arg, const std::string &filename_arg=std::string()) __attribute__((__deprecated__))
parse_error(const std::string &what_arg, const std::string &token_arg, const std::string &filename_arg, int line_arg)
Only use this version or the next one.
parse_error(const std::string &what_arg, const std::string &token_arg, int line_arg)
Only use this version or the previous one.
int line() const
permission_error(const std::string &filename="")
permission_error(const std::string &arg, const std::string &filename)
quota_exceeded_error(const std::string &filename="")
quota_exceeded_error(const std::string &arg, const std::string &filename)
read_write_error(const std::string &arg, const std::string &filename="")
stream_fail_error(const std::string &filename="")
stream_fail_error(const std::string &arg, const std::string &filename)
stream_state_error(const std::string &arg, const std::string &filename="")
syntax_check_error(const std::string &filename="")
syntax_check_error(const std::string &arg, const std::string &filename)
too_many_descriptors_error(const std::string &filename="")
too_many_descriptors_error(const std::string &arg, const std::string &filename)
wrong_format_error(const std::string &arg, const std::string &filename)
wrong_format_error(const std::string &filename="")
STL namespace.