1/** @file error.h
2 * @brief Hierarchy of classes which Xapian can throw as exceptions.
3 */
4/* Warning: This file is generated by /data/home/olly/tmp/xapian-svn-snapshot/tags/1.2.18/xapian/xapian-core/generate-exceptions - do not modify directly! */
5/* Copyright (C) 2003,2004,2006,2007,2009 Olly Betts
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (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, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef XAPIAN_INCLUDED_ERROR_H
23#define XAPIAN_INCLUDED_ERROR_H
24
25#include <string>
26#include <xapian/visibility.h>
27
28namespace Xapian {
29
30class ErrorHandler;
31
32/** All exceptions thrown by Xapian are subclasses of Xapian::Error.
33 *
34 * This class can not be instantiated directly - instead a subclass should
35 * be used.
36 */
37class XAPIAN_VISIBILITY_DEFAULT Error {
38 // ErrorHandler needs to be able to access Error::already_handled.
39 friend class ErrorHandler;
40
41 /// Message giving details of the error, intended for human consumption.
42 std::string msg;
43
44 /** Optional context information.
45 *
46 * This context is intended for use by Xapian::ErrorHandler (for example
47 * so it can know which remote server is unreliable and report the problem
48 * and remove that server from those being searched). But it's typically
49 * a plain-text string, and so also fit for human consumption.
50 */
51 std::string context;
52
53 /// The type of this error (e.g. DocNotFoundError.)
54 const char * type;
55
56 /** Optional value of 'errno' associated with this error.
57 *
58 * If no value is associated, this member variable will be 0.
59 *
60 * On UNIX, if this value is < 0, it's a negated h_errno value (giving
61 * an error from gethostbyname() or similar).
62 *
63 * On Windows, if this value is < 0, it's a negated Windows error code
64 * (as given by GetLastError() or WSAGetLastError()).
65 *
66 * NB We don't just call this member "errno" to avoid problems on
67 * platforms where errno is a preprocessor macro.
68 */
69 int my_errno;
70
71 /** The error string derived from my_errno.
72 *
73 * This string is generated from my_errno lazily.
74 */
75 mutable std::string error_string;
76
77 /// True if this error has already been passed to an ErrorHandler.
78 bool already_handled;
79
80 /// Don't allow assignment of the base class.
81 void operator=(const Error &o);
82
83 protected:
84 /** @private @internal
85 * @brief Constructor for use by constructors of derived classes.
86 */
87 Error(const std::string &msg_, const std::string &context_,
88 const char * type_, const char * error_string_);
89
90 /** @private @internal
91 * @brief Constructor for use by constructors of derived classes.
92 */
93 Error(const std::string &msg_, const std::string &context_,
94 const char * type_, int errno_)
95 : msg(msg_), context(context_), type(type_), my_errno(errno_),
96 error_string(), already_handled(false) { }
97
98 public:
99 /// The type of this error (e.g. "DocNotFoundError".)
100 const char * get_type() const { return type; }
101
102 /// Message giving details of the error, intended for human consumption.
103 const std::string & get_msg() const { return msg; }
104
105 /** Optional context information.
106 *
107 * This context is intended for use by Xapian::ErrorHandler (for example
108 * so it can know which remote server is unreliable and report the problem
109 * and remove that server from those being searched). But it's typically
110 * a plain-text string, and so also fit for human consumption.
111 */
112 const std::string & get_context() const { return context; }
113
114 /** Returns any system error string associated with this exception.
115 *
116 * The system error string may come from errno, h_errno (on UNIX), or
117 * GetLastError() (on MS Windows). If there is no associated system
118 * error string, NULL is returned.
119 */
120 const char * get_error_string() const;
121
122 /// Return a string describing this object.
123 std::string get_description() const;
124};
125
126/** The base class for exceptions indicating errors in the program logic.
127 *
128 * A subclass of LogicError will be thrown if Xapian detects a violation
129 * of a class invariant or a logical precondition or postcondition, etc.
130 */
131class XAPIAN_VISIBILITY_DEFAULT LogicError : public Error {
132 protected:
133 /** @private @internal
134 * @brief Constructor for use by constructors of derived classes.
135 */
136 LogicError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
137 : Error(msg_, context_, type_, error_string_) {}
138
139 /** @private @internal
140 * @brief Constructor for use by constructors of derived classes.
141 */
142 LogicError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
143 : Error(msg_, context_, type_, errno_) {}
144};
145
146/** The base class for exceptions indicating errors only detectable at runtime.
147 *
148 * A subclass of RuntimeError will be thrown if Xapian detects an error
149 * which is exception derived from RuntimeError is thrown when an
150 * error is caused by problems with the data or environment rather
151 * than a programming mistake.
152 */
153class XAPIAN_VISIBILITY_DEFAULT RuntimeError : public Error {
154 protected:
155 /** @private @internal
156 * @brief Constructor for use by constructors of derived classes.
157 */
158 RuntimeError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
159 : Error(msg_, context_, type_, error_string_) {}
160
161 /** @private @internal
162 * @brief Constructor for use by constructors of derived classes.
163 */
164 RuntimeError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
165 : Error(msg_, context_, type_, errno_) {}
166};
167
168/** AssertionError is thrown if a logical assertion inside Xapian fails.
169 *
170 * In a debug build of Xapian, a failed assertion in the core library code
171 * will cause AssertionError to be thrown.
172 *
173 * This represents a bug in Xapian (either an invariant, precondition, etc
174 * has been violated, or the assertion is incorrect!)
175 */
176class XAPIAN_VISIBILITY_DEFAULT AssertionError : public LogicError {
177 public:
178 /** @private @internal
179 * @brief Private constructor for use by remote backend.
180 *
181 * @param error_string_ Optional string describing error. May be NULL.
182 */
183 AssertionError(const std::string &msg_, const std::string &context_, const char * error_string_)
184 : LogicError(msg_, context_, "AssertionError", error_string_) {}
185 /** General purpose constructor.
186 *
187 * @param msg_ Message giving details of the error, intended
188 * for human consumption.
189 * @param context_ Optional context information for this error.
190 * @param errno_ Optional errno value associated with this error.
191 */
192 explicit AssertionError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
193 : LogicError(msg_, context_, "AssertionError", errno_) {}
194 /** Construct from message and errno value.
195 *
196 * @param msg_ Message giving details of the error, intended
197 * for human consumption.
198 * @param errno_ Optional errno value associated with this error.
199 */
200 AssertionError(const std::string &msg_, int errno_)
201 : LogicError(msg_, std::string(), "AssertionError", errno_) {}
202 protected:
203 /** @private @internal
204 * @brief Constructor for use by constructors of derived classes.
205 */
206 AssertionError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
207 : LogicError(msg_, context_, type_, error_string_) {}
208
209 /** @private @internal
210 * @brief Constructor for use by constructors of derived classes.
211 */
212 AssertionError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
213 : LogicError(msg_, context_, type_, errno_) {}
214};
215
216/** InvalidArgumentError indicates an invalid parameter value was passed to the API.
217*/
218class XAPIAN_VISIBILITY_DEFAULT InvalidArgumentError : public LogicError {
219 public:
220 /** @private @internal
221 * @brief Private constructor for use by remote backend.
222 *
223 * @param error_string_ Optional string describing error. May be NULL.
224 */
225 InvalidArgumentError(const std::string &msg_, const std::string &context_, const char * error_string_)
226 : LogicError(msg_, context_, "InvalidArgumentError", error_string_) {}
227 /** General purpose constructor.
228 *
229 * @param msg_ Message giving details of the error, intended
230 * for human consumption.
231 * @param context_ Optional context information for this error.
232 * @param errno_ Optional errno value associated with this error.
233 */
234 explicit InvalidArgumentError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
235 : LogicError(msg_, context_, "InvalidArgumentError", errno_) {}
236 /** Construct from message and errno value.
237 *
238 * @param msg_ Message giving details of the error, intended
239 * for human consumption.
240 * @param errno_ Optional errno value associated with this error.
241 */
242 InvalidArgumentError(const std::string &msg_, int errno_)
243 : LogicError(msg_, std::string(), "InvalidArgumentError", errno_) {}
244 protected:
245 /** @private @internal
246 * @brief Constructor for use by constructors of derived classes.
247 */
248 InvalidArgumentError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
249 : LogicError(msg_, context_, type_, error_string_) {}
250
251 /** @private @internal
252 * @brief Constructor for use by constructors of derived classes.
253 */
254 InvalidArgumentError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
255 : LogicError(msg_, context_, type_, errno_) {}
256};
257
258/** InvalidOperationError indicates the API was used in an invalid way.
259 */
260class XAPIAN_VISIBILITY_DEFAULT InvalidOperationError : public LogicError {
261 public:
262 /** @private @internal
263 * @brief Private constructor for use by remote backend.
264 *
265 * @param error_string_ Optional string describing error. May be NULL.
266 */
267 InvalidOperationError(const std::string &msg_, const std::string &context_, const char * error_string_)
268 : LogicError(msg_, context_, "InvalidOperationError", error_string_) {}
269 /** General purpose constructor.
270 *
271 * @param msg_ Message giving details of the error, intended
272 * for human consumption.
273 * @param context_ Optional context information for this error.
274 * @param errno_ Optional errno value associated with this error.
275 */
276 explicit InvalidOperationError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
277 : LogicError(msg_, context_, "InvalidOperationError", errno_) {}
278 /** Construct from message and errno value.
279 *
280 * @param msg_ Message giving details of the error, intended
281 * for human consumption.
282 * @param errno_ Optional errno value associated with this error.
283 */
284 InvalidOperationError(const std::string &msg_, int errno_)
285 : LogicError(msg_, std::string(), "InvalidOperationError", errno_) {}
286 protected:
287 /** @private @internal
288 * @brief Constructor for use by constructors of derived classes.
289 */
290 InvalidOperationError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
291 : LogicError(msg_, context_, type_, error_string_) {}
292
293 /** @private @internal
294 * @brief Constructor for use by constructors of derived classes.
295 */
296 InvalidOperationError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
297 : LogicError(msg_, context_, type_, errno_) {}
298};
299
300/** UnimplementedError indicates an attempt to use an unimplemented feature. */
301class XAPIAN_VISIBILITY_DEFAULT UnimplementedError : public LogicError {
302 public:
303 /** @private @internal
304 * @brief Private constructor for use by remote backend.
305 *
306 * @param error_string_ Optional string describing error. May be NULL.
307 */
308 UnimplementedError(const std::string &msg_, const std::string &context_, const char * error_string_)
309 : LogicError(msg_, context_, "UnimplementedError", error_string_) {}
310 /** General purpose constructor.
311 *
312 * @param msg_ Message giving details of the error, intended
313 * for human consumption.
314 * @param context_ Optional context information for this error.
315 * @param errno_ Optional errno value associated with this error.
316 */
317 explicit UnimplementedError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
318 : LogicError(msg_, context_, "UnimplementedError", errno_) {}
319 /** Construct from message and errno value.
320 *
321 * @param msg_ Message giving details of the error, intended
322 * for human consumption.
323 * @param errno_ Optional errno value associated with this error.
324 */
325 UnimplementedError(const std::string &msg_, int errno_)
326 : LogicError(msg_, std::string(), "UnimplementedError", errno_) {}
327 protected:
328 /** @private @internal
329 * @brief Constructor for use by constructors of derived classes.
330 */
331 UnimplementedError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
332 : LogicError(msg_, context_, type_, error_string_) {}
333
334 /** @private @internal
335 * @brief Constructor for use by constructors of derived classes.
336 */
337 UnimplementedError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
338 : LogicError(msg_, context_, type_, errno_) {}
339};
340
341/** DatabaseError indicates some sort of database related error. */
342class XAPIAN_VISIBILITY_DEFAULT DatabaseError : public RuntimeError {
343 public:
344 /** @private @internal
345 * @brief Private constructor for use by remote backend.
346 *
347 * @param error_string_ Optional string describing error. May be NULL.
348 */
349 DatabaseError(const std::string &msg_, const std::string &context_, const char * error_string_)
350 : RuntimeError(msg_, context_, "DatabaseError", error_string_) {}
351 /** General purpose constructor.
352 *
353 * @param msg_ Message giving details of the error, intended
354 * for human consumption.
355 * @param context_ Optional context information for this error.
356 * @param errno_ Optional errno value associated with this error.
357 */
358 explicit DatabaseError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
359 : RuntimeError(msg_, context_, "DatabaseError", errno_) {}
360 /** Construct from message and errno value.
361 *
362 * @param msg_ Message giving details of the error, intended
363 * for human consumption.
364 * @param errno_ Optional errno value associated with this error.
365 */
366 DatabaseError(const std::string &msg_, int errno_)
367 : RuntimeError(msg_, std::string(), "DatabaseError", errno_) {}
368 protected:
369 /** @private @internal
370 * @brief Constructor for use by constructors of derived classes.
371 */
372 DatabaseError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
373 : RuntimeError(msg_, context_, type_, error_string_) {}
374
375 /** @private @internal
376 * @brief Constructor for use by constructors of derived classes.
377 */
378 DatabaseError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
379 : RuntimeError(msg_, context_, type_, errno_) {}
380};
381
382/** DatabaseCorruptError indicates database corruption was detected. */
383class XAPIAN_VISIBILITY_DEFAULT DatabaseCorruptError : public DatabaseError {
384 public:
385 /** @private @internal
386 * @brief Private constructor for use by remote backend.
387 *
388 * @param error_string_ Optional string describing error. May be NULL.
389 */
390 DatabaseCorruptError(const std::string &msg_, const std::string &context_, const char * error_string_)
391 : DatabaseError(msg_, context_, "DatabaseCorruptError", error_string_) {}
392 /** General purpose constructor.
393 *
394 * @param msg_ Message giving details of the error, intended
395 * for human consumption.
396 * @param context_ Optional context information for this error.
397 * @param errno_ Optional errno value associated with this error.
398 */
399 explicit DatabaseCorruptError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
400 : DatabaseError(msg_, context_, "DatabaseCorruptError", errno_) {}
401 /** Construct from message and errno value.
402 *
403 * @param msg_ Message giving details of the error, intended
404 * for human consumption.
405 * @param errno_ Optional errno value associated with this error.
406 */
407 DatabaseCorruptError(const std::string &msg_, int errno_)
408 : DatabaseError(msg_, std::string(), "DatabaseCorruptError", errno_) {}
409 protected:
410 /** @private @internal
411 * @brief Constructor for use by constructors of derived classes.
412 */
413 DatabaseCorruptError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
414 : DatabaseError(msg_, context_, type_, error_string_) {}
415
416 /** @private @internal
417 * @brief Constructor for use by constructors of derived classes.
418 */
419 DatabaseCorruptError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
420 : DatabaseError(msg_, context_, type_, errno_) {}
421};
422
423/** DatabaseCreateError indicates a failure to create a database. */
424class XAPIAN_VISIBILITY_DEFAULT DatabaseCreateError : public DatabaseError {
425 public:
426 /** @private @internal
427 * @brief Private constructor for use by remote backend.
428 *
429 * @param error_string_ Optional string describing error. May be NULL.
430 */
431 DatabaseCreateError(const std::string &msg_, const std::string &context_, const char * error_string_)
432 : DatabaseError(msg_, context_, "DatabaseCreateError", error_string_) {}
433 /** General purpose constructor.
434 *
435 * @param msg_ Message giving details of the error, intended
436 * for human consumption.
437 * @param context_ Optional context information for this error.
438 * @param errno_ Optional errno value associated with this error.
439 */
440 explicit DatabaseCreateError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
441 : DatabaseError(msg_, context_, "DatabaseCreateError", errno_) {}
442 /** Construct from message and errno value.
443 *
444 * @param msg_ Message giving details of the error, intended
445 * for human consumption.
446 * @param errno_ Optional errno value associated with this error.
447 */
448 DatabaseCreateError(const std::string &msg_, int errno_)
449 : DatabaseError(msg_, std::string(), "DatabaseCreateError", errno_) {}
450 protected:
451 /** @private @internal
452 * @brief Constructor for use by constructors of derived classes.
453 */
454 DatabaseCreateError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
455 : DatabaseError(msg_, context_, type_, error_string_) {}
456
457 /** @private @internal
458 * @brief Constructor for use by constructors of derived classes.
459 */
460 DatabaseCreateError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
461 : DatabaseError(msg_, context_, type_, errno_) {}
462};
463
464/** DatabaseLockError indicates failure to lock a database. */
465class XAPIAN_VISIBILITY_DEFAULT DatabaseLockError : public DatabaseError {
466 public:
467 /** @private @internal
468 * @brief Private constructor for use by remote backend.
469 *
470 * @param error_string_ Optional string describing error. May be NULL.
471 */
472 DatabaseLockError(const std::string &msg_, const std::string &context_, const char * error_string_)
473 : DatabaseError(msg_, context_, "DatabaseLockError", error_string_) {}
474 /** General purpose constructor.
475 *
476 * @param msg_ Message giving details of the error, intended
477 * for human consumption.
478 * @param context_ Optional context information for this error.
479 * @param errno_ Optional errno value associated with this error.
480 */
481 explicit DatabaseLockError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
482 : DatabaseError(msg_, context_, "DatabaseLockError", errno_) {}
483 /** Construct from message and errno value.
484 *
485 * @param msg_ Message giving details of the error, intended
486 * for human consumption.
487 * @param errno_ Optional errno value associated with this error.
488 */
489 DatabaseLockError(const std::string &msg_, int errno_)
490 : DatabaseError(msg_, std::string(), "DatabaseLockError", errno_) {}
491 protected:
492 /** @private @internal
493 * @brief Constructor for use by constructors of derived classes.
494 */
495 DatabaseLockError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
496 : DatabaseError(msg_, context_, type_, error_string_) {}
497
498 /** @private @internal
499 * @brief Constructor for use by constructors of derived classes.
500 */
501 DatabaseLockError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
502 : DatabaseError(msg_, context_, type_, errno_) {}
503};
504
505/** DatabaseModifiedError indicates a database was modified.
506 *
507 * To recover after catching this error, you need to call
508 * Xapian::Database::reopen() on the Database and repeat the operation
509 * which failed.
510 */
511class XAPIAN_VISIBILITY_DEFAULT DatabaseModifiedError : public DatabaseError {
512 public:
513 /** @private @internal
514 * @brief Private constructor for use by remote backend.
515 *
516 * @param error_string_ Optional string describing error. May be NULL.
517 */
518 DatabaseModifiedError(const std::string &msg_, const std::string &context_, const char * error_string_)
519 : DatabaseError(msg_, context_, "DatabaseModifiedError", error_string_) {}
520 /** General purpose constructor.
521 *
522 * @param msg_ Message giving details of the error, intended
523 * for human consumption.
524 * @param context_ Optional context information for this error.
525 * @param errno_ Optional errno value associated with this error.
526 */
527 explicit DatabaseModifiedError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
528 : DatabaseError(msg_, context_, "DatabaseModifiedError", errno_) {}
529 /** Construct from message and errno value.
530 *
531 * @param msg_ Message giving details of the error, intended
532 * for human consumption.
533 * @param errno_ Optional errno value associated with this error.
534 */
535 DatabaseModifiedError(const std::string &msg_, int errno_)
536 : DatabaseError(msg_, std::string(), "DatabaseModifiedError", errno_) {}
537 protected:
538 /** @private @internal
539 * @brief Constructor for use by constructors of derived classes.
540 */
541 DatabaseModifiedError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
542 : DatabaseError(msg_, context_, type_, error_string_) {}
543
544 /** @private @internal
545 * @brief Constructor for use by constructors of derived classes.
546 */
547 DatabaseModifiedError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
548 : DatabaseError(msg_, context_, type_, errno_) {}
549};
550
551/** DatabaseOpeningError indicates failure to open a database. */
552class XAPIAN_VISIBILITY_DEFAULT DatabaseOpeningError : public DatabaseError {
553 public:
554 /** @private @internal
555 * @brief Private constructor for use by remote backend.
556 *
557 * @param error_string_ Optional string describing error. May be NULL.
558 */
559 DatabaseOpeningError(const std::string &msg_, const std::string &context_, const char * error_string_)
560 : DatabaseError(msg_, context_, "DatabaseOpeningError", error_string_) {}
561 /** General purpose constructor.
562 *
563 * @param msg_ Message giving details of the error, intended
564 * for human consumption.
565 * @param context_ Optional context information for this error.
566 * @param errno_ Optional errno value associated with this error.
567 */
568 explicit DatabaseOpeningError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
569 : DatabaseError(msg_, context_, "DatabaseOpeningError", errno_) {}
570 /** Construct from message and errno value.
571 *
572 * @param msg_ Message giving details of the error, intended
573 * for human consumption.
574 * @param errno_ Optional errno value associated with this error.
575 */
576 DatabaseOpeningError(const std::string &msg_, int errno_)
577 : DatabaseError(msg_, std::string(), "DatabaseOpeningError", errno_) {}
578 protected:
579 /** @private @internal
580 * @brief Constructor for use by constructors of derived classes.
581 */
582 DatabaseOpeningError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
583 : DatabaseError(msg_, context_, type_, error_string_) {}
584
585 /** @private @internal
586 * @brief Constructor for use by constructors of derived classes.
587 */
588 DatabaseOpeningError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
589 : DatabaseError(msg_, context_, type_, errno_) {}
590};
591
592/** DatabaseVersionError indicates that a database is in an unsupported format.
593 *
594 * From time to time, new versions of Xapian will require the database format
595 * to be changed, to allow new information to be stored or new optimisations
596 * to be performed. Backwards compatibility will sometimes be maintained, so
597 * that new versions of Xapian can open old databases, but in some cases
598 * Xapian will be unable to open a database because it is in too old (or new)
599 * a format. This can be resolved either be upgrading or downgrading the
600 * version of Xapian in use, or by rebuilding the database from scratch with
601 * the current version of Xapian.
602 */
603class XAPIAN_VISIBILITY_DEFAULT DatabaseVersionError : public DatabaseOpeningError {
604 public:
605 /** @private @internal
606 * @brief Private constructor for use by remote backend.
607 *
608 * @param error_string_ Optional string describing error. May be NULL.
609 */
610 DatabaseVersionError(const std::string &msg_, const std::string &context_, const char * error_string_)
611 : DatabaseOpeningError(msg_, context_, "DatabaseVersionError", error_string_) {}
612 /** General purpose constructor.
613 *
614 * @param msg_ Message giving details of the error, intended
615 * for human consumption.
616 * @param context_ Optional context information for this error.
617 * @param errno_ Optional errno value associated with this error.
618 */
619 explicit DatabaseVersionError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
620 : DatabaseOpeningError(msg_, context_, "DatabaseVersionError", errno_) {}
621 /** Construct from message and errno value.
622 *
623 * @param msg_ Message giving details of the error, intended
624 * for human consumption.
625 * @param errno_ Optional errno value associated with this error.
626 */
627 DatabaseVersionError(const std::string &msg_, int errno_)
628 : DatabaseOpeningError(msg_, std::string(), "DatabaseVersionError", errno_) {}
629 protected:
630 /** @private @internal
631 * @brief Constructor for use by constructors of derived classes.
632 */
633 DatabaseVersionError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
634 : DatabaseOpeningError(msg_, context_, type_, error_string_) {}
635
636 /** @private @internal
637 * @brief Constructor for use by constructors of derived classes.
638 */
639 DatabaseVersionError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
640 : DatabaseOpeningError(msg_, context_, type_, errno_) {}
641};
642
643/** Indicates an attempt to access a document not present in the database. */
644class XAPIAN_VISIBILITY_DEFAULT DocNotFoundError : public RuntimeError {
645 public:
646 /** @private @internal
647 * @brief Private constructor for use by remote backend.
648 *
649 * @param error_string_ Optional string describing error. May be NULL.
650 */
651 DocNotFoundError(const std::string &msg_, const std::string &context_, const char * error_string_)
652 : RuntimeError(msg_, context_, "DocNotFoundError", error_string_) {}
653 /** General purpose constructor.
654 *
655 * @param msg_ Message giving details of the error, intended
656 * for human consumption.
657 * @param context_ Optional context information for this error.
658 * @param errno_ Optional errno value associated with this error.
659 */
660 explicit DocNotFoundError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
661 : RuntimeError(msg_, context_, "DocNotFoundError", errno_) {}
662 /** Construct from message and errno value.
663 *
664 * @param msg_ Message giving details of the error, intended
665 * for human consumption.
666 * @param errno_ Optional errno value associated with this error.
667 */
668 DocNotFoundError(const std::string &msg_, int errno_)
669 : RuntimeError(msg_, std::string(), "DocNotFoundError", errno_) {}
670 protected:
671 /** @private @internal
672 * @brief Constructor for use by constructors of derived classes.
673 */
674 DocNotFoundError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
675 : RuntimeError(msg_, context_, type_, error_string_) {}
676
677 /** @private @internal
678 * @brief Constructor for use by constructors of derived classes.
679 */
680 DocNotFoundError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
681 : RuntimeError(msg_, context_, type_, errno_) {}
682};
683
684/** Indicates an attempt to use a feature which is unavailable.
685 *
686 * Typically a feature is unavailable because it wasn't compiled in, or
687 * because it requires other software or facilities which aren't available.
688 */
689class XAPIAN_VISIBILITY_DEFAULT FeatureUnavailableError : public RuntimeError {
690 public:
691 /** @private @internal
692 * @brief Private constructor for use by remote backend.
693 *
694 * @param error_string_ Optional string describing error. May be NULL.
695 */
696 FeatureUnavailableError(const std::string &msg_, const std::string &context_, const char * error_string_)
697 : RuntimeError(msg_, context_, "FeatureUnavailableError", error_string_) {}
698 /** General purpose constructor.
699 *
700 * @param msg_ Message giving details of the error, intended
701 * for human consumption.
702 * @param context_ Optional context information for this error.
703 * @param errno_ Optional errno value associated with this error.
704 */
705 explicit FeatureUnavailableError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
706 : RuntimeError(msg_, context_, "FeatureUnavailableError", errno_) {}
707 /** Construct from message and errno value.
708 *
709 * @param msg_ Message giving details of the error, intended
710 * for human consumption.
711 * @param errno_ Optional errno value associated with this error.
712 */
713 FeatureUnavailableError(const std::string &msg_, int errno_)
714 : RuntimeError(msg_, std::string(), "FeatureUnavailableError", errno_) {}
715 protected:
716 /** @private @internal
717 * @brief Constructor for use by constructors of derived classes.
718 */
719 FeatureUnavailableError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
720 : RuntimeError(msg_, context_, type_, error_string_) {}
721
722 /** @private @internal
723 * @brief Constructor for use by constructors of derived classes.
724 */
725 FeatureUnavailableError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
726 : RuntimeError(msg_, context_, type_, errno_) {}
727};
728
729/** InternalError indicates a runtime problem of some sort. */
730class XAPIAN_VISIBILITY_DEFAULT InternalError : public RuntimeError {
731 public:
732 /** @private @internal
733 * @brief Private constructor for use by remote backend.
734 *
735 * @param error_string_ Optional string describing error. May be NULL.
736 */
737 InternalError(const std::string &msg_, const std::string &context_, const char * error_string_)
738 : RuntimeError(msg_, context_, "InternalError", error_string_) {}
739 /** General purpose constructor.
740 *
741 * @param msg_ Message giving details of the error, intended
742 * for human consumption.
743 * @param context_ Optional context information for this error.
744 * @param errno_ Optional errno value associated with this error.
745 */
746 explicit InternalError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
747 : RuntimeError(msg_, context_, "InternalError", errno_) {}
748 /** Construct from message and errno value.
749 *
750 * @param msg_ Message giving details of the error, intended
751 * for human consumption.
752 * @param errno_ Optional errno value associated with this error.
753 */
754 InternalError(const std::string &msg_, int errno_)
755 : RuntimeError(msg_, std::string(), "InternalError", errno_) {}
756 protected:
757 /** @private @internal
758 * @brief Constructor for use by constructors of derived classes.
759 */
760 InternalError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
761 : RuntimeError(msg_, context_, type_, error_string_) {}
762
763 /** @private @internal
764 * @brief Constructor for use by constructors of derived classes.
765 */
766 InternalError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
767 : RuntimeError(msg_, context_, type_, errno_) {}
768};
769
770/** Indicates a problem communicating with a remote database. */
771class XAPIAN_VISIBILITY_DEFAULT NetworkError : public RuntimeError {
772 public:
773 /** @private @internal
774 * @brief Private constructor for use by remote backend.
775 *
776 * @param error_string_ Optional string describing error. May be NULL.
777 */
778 NetworkError(const std::string &msg_, const std::string &context_, const char * error_string_)
779 : RuntimeError(msg_, context_, "NetworkError", error_string_) {}
780 /** General purpose constructor.
781 *
782 * @param msg_ Message giving details of the error, intended
783 * for human consumption.
784 * @param context_ Optional context information for this error.
785 * @param errno_ Optional errno value associated with this error.
786 */
787 explicit NetworkError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
788 : RuntimeError(msg_, context_, "NetworkError", errno_) {}
789 /** Construct from message and errno value.
790 *
791 * @param msg_ Message giving details of the error, intended
792 * for human consumption.
793 * @param errno_ Optional errno value associated with this error.
794 */
795 NetworkError(const std::string &msg_, int errno_)
796 : RuntimeError(msg_, std::string(), "NetworkError", errno_) {}
797 protected:
798 /** @private @internal
799 * @brief Constructor for use by constructors of derived classes.
800 */
801 NetworkError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
802 : RuntimeError(msg_, context_, type_, error_string_) {}
803
804 /** @private @internal
805 * @brief Constructor for use by constructors of derived classes.
806 */
807 NetworkError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
808 : RuntimeError(msg_, context_, type_, errno_) {}
809};
810
811/** Indicates a timeout expired while communicating with a remote database. */
812class XAPIAN_VISIBILITY_DEFAULT NetworkTimeoutError : public NetworkError {
813 public:
814 /** @private @internal
815 * @brief Private constructor for use by remote backend.
816 *
817 * @param error_string_ Optional string describing error. May be NULL.
818 */
819 NetworkTimeoutError(const std::string &msg_, const std::string &context_, const char * error_string_)
820 : NetworkError(msg_, context_, "NetworkTimeoutError", error_string_) {}
821 /** General purpose constructor.
822 *
823 * @param msg_ Message giving details of the error, intended
824 * for human consumption.
825 * @param context_ Optional context information for this error.
826 * @param errno_ Optional errno value associated with this error.
827 */
828 explicit NetworkTimeoutError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
829 : NetworkError(msg_, context_, "NetworkTimeoutError", errno_) {}
830 /** Construct from message and errno value.
831 *
832 * @param msg_ Message giving details of the error, intended
833 * for human consumption.
834 * @param errno_ Optional errno value associated with this error.
835 */
836 NetworkTimeoutError(const std::string &msg_, int errno_)
837 : NetworkError(msg_, std::string(), "NetworkTimeoutError", errno_) {}
838 protected:
839 /** @private @internal
840 * @brief Constructor for use by constructors of derived classes.
841 */
842 NetworkTimeoutError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
843 : NetworkError(msg_, context_, type_, error_string_) {}
844
845 /** @private @internal
846 * @brief Constructor for use by constructors of derived classes.
847 */
848 NetworkTimeoutError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
849 : NetworkError(msg_, context_, type_, errno_) {}
850};
851
852/** Indicates a query string can't be parsed. */
853class XAPIAN_VISIBILITY_DEFAULT QueryParserError : public RuntimeError {
854 public:
855 /** @private @internal
856 * @brief Private constructor for use by remote backend.
857 *
858 * @param error_string_ Optional string describing error. May be NULL.
859 */
860 QueryParserError(const std::string &msg_, const std::string &context_, const char * error_string_)
861 : RuntimeError(msg_, context_, "QueryParserError", error_string_) {}
862 /** General purpose constructor.
863 *
864 * @param msg_ Message giving details of the error, intended
865 * for human consumption.
866 * @param context_ Optional context information for this error.
867 * @param errno_ Optional errno value associated with this error.
868 */
869 explicit QueryParserError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
870 : RuntimeError(msg_, context_, "QueryParserError", errno_) {}
871 /** Construct from message and errno value.
872 *
873 * @param msg_ Message giving details of the error, intended
874 * for human consumption.
875 * @param errno_ Optional errno value associated with this error.
876 */
877 QueryParserError(const std::string &msg_, int errno_)
878 : RuntimeError(msg_, std::string(), "QueryParserError", errno_) {}
879 protected:
880 /** @private @internal
881 * @brief Constructor for use by constructors of derived classes.
882 */
883 QueryParserError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
884 : RuntimeError(msg_, context_, type_, error_string_) {}
885
886 /** @private @internal
887 * @brief Constructor for use by constructors of derived classes.
888 */
889 QueryParserError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
890 : RuntimeError(msg_, context_, type_, errno_) {}
891};
892
893/** Indicates an error in the std::string serialisation of an object. */
894class XAPIAN_VISIBILITY_DEFAULT SerialisationError : public RuntimeError {
895 public:
896 /** @private @internal
897 * @brief Private constructor for use by remote backend.
898 *
899 * @param error_string_ Optional string describing error. May be NULL.
900 */
901 SerialisationError(const std::string &msg_, const std::string &context_, const char * error_string_)
902 : RuntimeError(msg_, context_, "SerialisationError", error_string_) {}
903 /** General purpose constructor.
904 *
905 * @param msg_ Message giving details of the error, intended
906 * for human consumption.
907 * @param context_ Optional context information for this error.
908 * @param errno_ Optional errno value associated with this error.
909 */
910 explicit SerialisationError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
911 : RuntimeError(msg_, context_, "SerialisationError", errno_) {}
912 /** Construct from message and errno value.
913 *
914 * @param msg_ Message giving details of the error, intended
915 * for human consumption.
916 * @param errno_ Optional errno value associated with this error.
917 */
918 SerialisationError(const std::string &msg_, int errno_)
919 : RuntimeError(msg_, std::string(), "SerialisationError", errno_) {}
920 protected:
921 /** @private @internal
922 * @brief Constructor for use by constructors of derived classes.
923 */
924 SerialisationError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
925 : RuntimeError(msg_, context_, type_, error_string_) {}
926
927 /** @private @internal
928 * @brief Constructor for use by constructors of derived classes.
929 */
930 SerialisationError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
931 : RuntimeError(msg_, context_, type_, errno_) {}
932};
933
934/** RangeError indicates an attempt to access outside the bounds of a container.
935 */
936class XAPIAN_VISIBILITY_DEFAULT RangeError : public RuntimeError {
937 public:
938 /** @private @internal
939 * @brief Private constructor for use by remote backend.
940 *
941 * @param error_string_ Optional string describing error. May be NULL.
942 */
943 RangeError(const std::string &msg_, const std::string &context_, const char * error_string_)
944 : RuntimeError(msg_, context_, "RangeError", error_string_) {}
945 /** General purpose constructor.
946 *
947 * @param msg_ Message giving details of the error, intended
948 * for human consumption.
949 * @param context_ Optional context information for this error.
950 * @param errno_ Optional errno value associated with this error.
951 */
952 explicit RangeError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
953 : RuntimeError(msg_, context_, "RangeError", errno_) {}
954 /** Construct from message and errno value.
955 *
956 * @param msg_ Message giving details of the error, intended
957 * for human consumption.
958 * @param errno_ Optional errno value associated with this error.
959 */
960 RangeError(const std::string &msg_, int errno_)
961 : RuntimeError(msg_, std::string(), "RangeError", errno_) {}
962 protected:
963 /** @private @internal
964 * @brief Constructor for use by constructors of derived classes.
965 */
966 RangeError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
967 : RuntimeError(msg_, context_, type_, error_string_) {}
968
969 /** @private @internal
970 * @brief Constructor for use by constructors of derived classes.
971 */
972 RangeError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
973 : RuntimeError(msg_, context_, type_, errno_) {}
974};
975
976}
977
978#endif /* XAPIAN_INCLUDED_ERROR_H */
979