| Disk ARchive 2.5.10 Full featured and portable backup and archiving tool

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

erreurs.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program 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 General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26 #ifndef ERREURS_HPP
27 #define ERREURS_HPP
28
29 #include "../my_config.h"
30
31 #include <string>
32 #include <list>
33 #include "integers.hpp"
34 #include "erreurs.hpp"
35
36 namespace libdar
37 {
38
41
43 extern const char *dar_gettext(const char *);
44
46
52 class Egeneric
53 {
54 public :
56 Egeneric(const std::string &source, const std::string &message);
58 virtual ~Egeneric() {};
59
61 virtual void stack(const std::string & passage, const std::string & message = "") { pile.push_back(niveau(passage, message)); };
62
64
69 const std::string & get_message() const { return pile.front().objet; };
70
72 const std::string & get_source() const { return pile.front().lieu; };
73
75
78 const std::string & find_object(const std::string & location) const;
79
81 void prepend_message(const std::string & context);
82
86 void dump() const;
87
89 std::string dump_str() const;
90
91 protected :
92 virtual std::string exceptionID() const = 0;
93
94 private :
95 struct niveau
96 {
97 niveau(const std::string &ou, const std::string &quoi) { lieu = ou; objet = quoi; };
98 std::string lieu, objet;
99 };
100
101 std::list<niveau> pile;
102
103 static const std::string empty_string;
104 };
105
106
108
111 class Ememory : public Egeneric
112 {
113 public:
114 Ememory(const std::string &source) : Egeneric(source, dar_gettext("Lack of Memory")) {};
115
116 protected:
117 Ememory(const std::string &source, const std::string & message) : Egeneric(source, message) {};
118 std::string exceptionID() const { return "MEMORY"; };
119 };
120
122
123 class Esecu_memory : public Ememory
124 {
125 public:
126 Esecu_memory(const std::string &source) : Ememory(source, dar_gettext("Lack of Secured Memory")) {};
127
128 protected:
129 std::string exceptionID() const { return "SECU_MEMORY"; };
130 };
131
132
133 #define SRC_BUG Ebug(__FILE__, __LINE__)
134 // #define XMT_BUG(exception, call) exception.stack(call, __FILE__, __LINE__)
135
137 class Ebug : public Egeneric
138 {
139 public :
140 Ebug(const std::string & file, S_I line);
141
142 using Egeneric::stack; // to avoid warning with clang
143 void stack(const std::string & passage, const std::string & file, const std::string & line);
144
145 protected :
146 std::string exceptionID() const { return "BUG"; };
147 };
148
150
153 class Einfinint : public Egeneric
154 {
155 public :
156 Einfinint(const std::string & source, const std::string & message) : Egeneric(source, message) {};
157
158 protected :
159 std::string exceptionID() const { return "INFININT"; };
160 };
161
163
166 class Elimitint : public Egeneric
167 {
168 public :
169 Elimitint() : Egeneric("", dar_gettext("Cannot handle such a too large integer. Use a full version of libdar (compiled to rely on the \"infinint\" integer type) to solve this problem")) {};
170
171 protected :
172 std::string exceptionID() const { return "LIMITINT"; };
173 };
174
176
179 class Erange : public Egeneric
180 {
181 public :
182 Erange(const std::string & source, const std::string & message) : Egeneric(source, message) {};
183
184 protected :
185 std::string exceptionID() const { return "RANGE"; };
186 };
187
189
193 class Edeci : public Egeneric
194 {
195 public :
196 Edeci(const std::string & source, const std::string & message) : Egeneric(source, message) {};
197
198 protected :
199 std::string exceptionID() const { return "DECI"; };
200 };
201
203
206 class Efeature : public Egeneric
207 {
208 public :
209 Efeature(const std::string & message) : Egeneric("", message) {};
210
211 protected :
212 std::string exceptionID() const { return "UNIMPLEMENTED FEATURE"; };
213 };
214
216
219 class Ehardware : public Egeneric
220 {
221 public :
222 Ehardware(const std::string & source, const std::string & message) : Egeneric(source, message) {};
223
224 protected :
225 std::string exceptionID() const { return "HARDWARE ERROR"; };
226 };
227
229
232 class Euser_abort : public Egeneric
233 {
234 public :
235 Euser_abort(const std::string & msg) : Egeneric("",msg) {};
236
237 protected :
238 std::string exceptionID() const { return "USER ABORTED OPERATION"; };
239 };
240
241
243
246 class Edata : public Egeneric
247 {
248 public :
249 Edata(const std::string & msg) : Egeneric("", msg) {};
250
251 protected :
252 std::string exceptionID() const { return "ERROR IN TREATED DATA"; };
253 };
254
256
259 class Escript : public Egeneric
260 {
261 public :
262 Escript(const std::string & source, const std::string & msg) : Egeneric(source ,msg) {};
263
264 protected :
265 std::string exceptionID() const { return "USER ABORTED OPERATION"; };
266 };
267
269
272 class Elibcall : public Egeneric
273 {
274 public :
275 Elibcall(const std::string & source, const std::string & msg) : Egeneric(source ,msg) {};
276
277 protected :
278 std::string exceptionID() const { return "USER ABORTED OPERATION"; };
279 };
280
282
285 class Ecompilation : public Egeneric
286 {
287 public :
288 Ecompilation(const std::string & msg) : Egeneric("" ,msg) {};
289
290 protected :
291 std::string exceptionID() const { return "FEATURE DISABLED AT COMPILATION TIME"; };
292 };
293
294
296
297 class Ethread_cancel : public Egeneric
298 {
299 public:
300 Ethread_cancel(bool now, U_64 x_flag) : Egeneric("", now ? dar_gettext("Thread cancellation requested, aborting as soon as possible") : dar_gettext("Thread cancellation requested, aborting as properly as possible")) { immediate = now; flag = x_flag; };
301
302 bool immediate_cancel() const { return immediate; };
303 U_64 get_flag() const { return flag; };
304
305 protected:
306 std::string exceptionID() const { return "THREAD CANCELLATION REQUESTED, ABORTING"; };
307
308 private:
309 bool immediate;
310 U_64 flag;
311 };
312
314
315 class Esystem : public Egeneric
316 {
317 public:
318 enum io_error
319 {
320 io_exist, //< file already exists (write mode)
321 io_absent, //< file does not exist (read mode)
322 io_access //< permission denied (any mode)
323 };
324
325 Esystem(const std::string & source, const std::string & message, io_error code);
326
327 io_error get_code() const { return x_code; };
328
329 protected:
330 virtual std::string exceptionID() const { return "SYSTEM ERROR MET"; };
331
332 private:
333 io_error x_code;
334 };
335
336
338
339 } // end of namespace
340
341 #endif
libdar::Elibcall
exception used to signal an error in the argument given to libdar call of the API ...
Definition: erreurs.hpp:272
libdar::Egeneric::~Egeneric
virtual ~Egeneric()
the destructor
Definition: erreurs.hpp:58
integers.hpp
are defined here basic integer types that tend to be portable
libdar::Egeneric::find_object
const std::string & find_object(const std::string &location) const
retrieve the objet (object) associated to a given "lieu" (location) from the stack ...
libdar::Esystem
exception used to carry system error
Definition: erreurs.hpp:315
libdar::Egeneric::dump
void dump() const
libdar::Egeneric::Egeneric
Egeneric(const std::string &source, const std::string &message)
the constructor
libdar::dar_gettext
const char * dar_gettext(const char *)
a routine to change NLS domaine forth and back for inline routines
libdar::Ehardware
exception used when hardware problem is found
Definition: erreurs.hpp:219
libdar::Ecompilation
exception used when a requested fearture has not beed activated at compilation time ...
Definition: erreurs.hpp:285
libdar::Egeneric
this is the parent class of all exception classes.
Definition: erreurs.hpp:52
libdar::Elimitint
exception used when a limitint overflow is detected, the maximum value of the limitint has been excee...
Definition: erreurs.hpp:166
libdar::Egeneric::stack
virtual void stack(const std::string &passage, const std::string &message="")
add more detailed couple of information to the exception
Definition: erreurs.hpp:61
libdar::Edata
exception used when an error concerning the treated data has been met
Definition: erreurs.hpp:246
libdar::Esecu_memory
exception used when secure memory has been exhausted
Definition: erreurs.hpp:123
libdar::Ethread_cancel
exception used when the thread libdar is running in is asked to stop
Definition: erreurs.hpp:297
libdar::Ememory
exception used when memory has been exhausted
Definition: erreurs.hpp:111
libdar::Efeature
exception used when a requested feature is not (yet) implemented
Definition: erreurs.hpp:206
libdar::Einfinint
exception used when arithmetic error is detected when operating on infinint
Definition: erreurs.hpp:153
libdar::Edeci
exception used to signal convertion problem between infinint and string (decimal representation) ...
Definition: erreurs.hpp:193
libdar::Egeneric::get_message
const std::string & get_message() const
get the message explaing the nature of the exception
Definition: erreurs.hpp:69
erreurs.hpp
contains all the excetion class thrown by libdar
libdar::Erange
exception used to signal range error
Definition: erreurs.hpp:179
libdar::Egeneric::get_source
const std::string & get_source() const
get the call function which has thrown this exception
Definition: erreurs.hpp:72
libdar::Ebug
exception used to signal a bug. A bug is triggered when reaching some code that should never be reach...
Definition: erreurs.hpp:137
libdar::Egeneric::prepend_message
void prepend_message(const std::string &context)
prepend error message by the given string
libdar::Egeneric::dump_str
std::string dump_str() const
return a string result of the exception information dump
libdar::Euser_abort
exception used to signal that the user has aborted the operation
Definition: erreurs.hpp:232
libdar::Escript
exception used when error the inter-slice user command returned an error code
Definition: erreurs.hpp:259
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47