PageRenderTime 57ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/xapian-core-1.0.11/include/xapian/error.h

https://github.com/kyeh/dormhost
C Header | 755 lines | 300 code | 63 blank | 392 comment | 0 complexity | 78473afbaef9de23ea35a2583ddb5c26 MD5 | raw file
Possible License(s): GPL-2.0, MIT
  1. /** @file error.h
  2. * @brief Hierarchy of classes which Xapian can throw as exceptions.
  3. */
  4. /* Warning: This file is generated by ./generate-exceptions - do not modify directly! */
  5. /* Copyright (C) 2003,2004,2006,2007 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. #ifndef XAPIAN_INCLUDED_ERROR_H
  22. #define XAPIAN_INCLUDED_ERROR_H
  23. #include <string>
  24. #include <xapian/deprecated.h>
  25. #include <xapian/visibility.h>
  26. namespace Xapian {
  27. class ErrorHandler;
  28. /** All exceptions thrown by Xapian are subclasses of Xapian::Error.
  29. *
  30. * This class can not be instantiated directly - instead a subclass should
  31. * be used.
  32. */
  33. class XAPIAN_VISIBILITY_DEFAULT Error {
  34. // ErrorHandler needs to be able to access Error::already_handled.
  35. friend class ErrorHandler;
  36. /// Message giving details of the error, intended for human consumption.
  37. std::string msg;
  38. /** Optional context information.
  39. *
  40. * This context is intended for use by Xapian::ErrorHandler (for example
  41. * so it can know which remote server is unreliable and report the problem
  42. * and remove that server from those being searched). But it's typically
  43. * a plain-text string, and so also fit for human consumption.
  44. */
  45. std::string context;
  46. /// The type of this error (e.g. DocNotFoundError.)
  47. const char * type;
  48. /** Optional value of 'errno' associated with this error.
  49. *
  50. * If no value is associated, this member variable will be 0.
  51. *
  52. * On UNIX, if this value is < 0, it's a negated h_errno value (giving
  53. * an error from gethostbyname() or similar).
  54. *
  55. * On Windows, if this value is < 0, it's a negated Windows error code
  56. * (as given by GetLastError() or WSAGetLastError()).
  57. *
  58. * NB We don't just call this member "errno" to avoid problems on
  59. * platforms where errno is a preprocessor macro.
  60. */
  61. int my_errno;
  62. /** The error string derived from my_errno.
  63. *
  64. * This string is generated from my_errno lazily.
  65. */
  66. mutable std::string error_string;
  67. /// True if this error has already been passed to an ErrorHandler.
  68. bool already_handled;
  69. /// Don't allow assignment of the base class.
  70. void operator=(const Error &o);
  71. protected:
  72. /** @private @internal
  73. * @brief Constructor for use by constructors of derived classes.
  74. */
  75. Error(const std::string &msg_, const std::string &context_,
  76. const char * type_, const char * error_string_);
  77. /** @private @internal
  78. * @brief Constructor for use by constructors of derived classes.
  79. */
  80. Error(const std::string &msg_, const std::string &context_,
  81. const char * type_, int errno_)
  82. : msg(msg_), context(context_), type(type_), my_errno(errno_),
  83. error_string(), already_handled(false) { }
  84. public:
  85. /// The type of this error (e.g. "DocNotFoundError".)
  86. const char * get_type() const { return type; }
  87. /// Message giving details of the error, intended for human consumption.
  88. const std::string & get_msg() const { return msg; }
  89. /** Optional context information.
  90. *
  91. * This context is intended for use by Xapian::ErrorHandler (for example
  92. * so it can know which remote server is unreliable and report the problem
  93. * and remove that server from those being searched). But it's typically
  94. * a plain-text string, and so also fit for human consumption.
  95. */
  96. const std::string & get_context() const { return context; }
  97. /** Returns any system error string associated with this exception.
  98. *
  99. * The system error string may come from errno, h_errno (on UNIX), or
  100. * GetLastError() (on MS Windows). If there is no associated system
  101. * error string, NULL is returned.
  102. */
  103. const char * get_error_string() const;
  104. /** Optional value of 'errno' associated with this error.
  105. *
  106. * If no 'errno' value is associated, returns 0. If the returned value
  107. * is negative, it's a platform-specific error code (on UNIX, -h_errno;
  108. * on MS Windows, -GetLastError()).
  109. *
  110. * @deprecated This method is deprecated, because errno values aren't
  111. * portable between platforms, so we can't serialise them when passing
  112. * exceptions from a remote server to a client. Use the
  113. * get_error_string() method instead.
  114. */
  115. XAPIAN_DEPRECATED(int get_errno() const);
  116. /// Return a string describing this object.
  117. std::string get_description() const;
  118. };
  119. inline int Xapian::Error::get_errno() const { return my_errno; }
  120. /** The base class for exceptions indicating errors in the program logic.
  121. *
  122. * A subclass of LogicError will be thrown if Xapian detects a violation
  123. * of a class invariant or a logical precondition or postcondition, etc.
  124. */
  125. class XAPIAN_VISIBILITY_DEFAULT LogicError : public Error {
  126. protected:
  127. /** @private @internal
  128. * @brief Constructor for use by constructors of derived classes.
  129. */
  130. LogicError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  131. : Error(msg_, context_, type_, error_string_) {}
  132. /** @private @internal
  133. * @brief Constructor for use by constructors of derived classes.
  134. */
  135. LogicError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  136. : Error(msg_, context_, type_, errno_) {}
  137. };
  138. /** The base class for exceptions indicating errors only detectable at runtime.
  139. *
  140. * A subclass of RuntimeError will be thrown if Xapian detects an error
  141. * which is exception derived from RuntimeError is thrown when an
  142. * error is caused by problems with the data or environment rather
  143. * than a programming mistake.
  144. */
  145. class XAPIAN_VISIBILITY_DEFAULT RuntimeError : public Error {
  146. protected:
  147. /** @private @internal
  148. * @brief Constructor for use by constructors of derived classes.
  149. */
  150. RuntimeError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  151. : Error(msg_, context_, type_, error_string_) {}
  152. /** @private @internal
  153. * @brief Constructor for use by constructors of derived classes.
  154. */
  155. RuntimeError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  156. : Error(msg_, context_, type_, errno_) {}
  157. };
  158. /** AssertionError is thrown if a logical assertion inside Xapian fails.
  159. *
  160. * In a debug build of Xapian, a failed assertion in the core library code
  161. * will cause AssertionError to be thrown.
  162. *
  163. * This represents a bug in Xapian (either an invariant, precondition, etc
  164. * has been violated, or the assertion is incorrect!)
  165. */
  166. class XAPIAN_VISIBILITY_DEFAULT AssertionError : public LogicError {
  167. public:
  168. /** @private @internal
  169. * @brief Private constructor for use by remote backend.
  170. *
  171. * @param error_string_ Optional string describing error. May be NULL.
  172. */
  173. AssertionError(const std::string &msg_, const std::string &context_, const char * error_string_)
  174. : LogicError(msg_, context_, "AssertionError", error_string_) {}
  175. /** General purpose constructor which allows setting errno. */
  176. explicit AssertionError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  177. : LogicError(msg_, context_, "AssertionError", errno_) {}
  178. /** Construct from message and errno value. */
  179. AssertionError(const std::string &msg_, int errno_)
  180. : LogicError(msg_, "", "AssertionError", errno_) {}
  181. protected:
  182. /** @private @internal
  183. * @brief Constructor for use by constructors of derived classes.
  184. */
  185. AssertionError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  186. : LogicError(msg_, context_, type_, error_string_) {}
  187. /** @private @internal
  188. * @brief Constructor for use by constructors of derived classes.
  189. */
  190. AssertionError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  191. : LogicError(msg_, context_, type_, errno_) {}
  192. };
  193. /** InvalidArgumentError indicates an invalid parameter value was passed to the API.
  194. */
  195. class XAPIAN_VISIBILITY_DEFAULT InvalidArgumentError : public LogicError {
  196. public:
  197. /** @private @internal
  198. * @brief Private constructor for use by remote backend.
  199. *
  200. * @param error_string_ Optional string describing error. May be NULL.
  201. */
  202. InvalidArgumentError(const std::string &msg_, const std::string &context_, const char * error_string_)
  203. : LogicError(msg_, context_, "InvalidArgumentError", error_string_) {}
  204. /** General purpose constructor which allows setting errno. */
  205. explicit InvalidArgumentError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  206. : LogicError(msg_, context_, "InvalidArgumentError", errno_) {}
  207. /** Construct from message and errno value. */
  208. InvalidArgumentError(const std::string &msg_, int errno_)
  209. : LogicError(msg_, "", "InvalidArgumentError", errno_) {}
  210. protected:
  211. /** @private @internal
  212. * @brief Constructor for use by constructors of derived classes.
  213. */
  214. InvalidArgumentError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  215. : LogicError(msg_, context_, type_, error_string_) {}
  216. /** @private @internal
  217. * @brief Constructor for use by constructors of derived classes.
  218. */
  219. InvalidArgumentError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  220. : LogicError(msg_, context_, type_, errno_) {}
  221. };
  222. /** InvalidOperationError indicates the API was used in an invalid way.
  223. */
  224. class XAPIAN_VISIBILITY_DEFAULT InvalidOperationError : public LogicError {
  225. public:
  226. /** @private @internal
  227. * @brief Private constructor for use by remote backend.
  228. *
  229. * @param error_string_ Optional string describing error. May be NULL.
  230. */
  231. InvalidOperationError(const std::string &msg_, const std::string &context_, const char * error_string_)
  232. : LogicError(msg_, context_, "InvalidOperationError", error_string_) {}
  233. /** General purpose constructor which allows setting errno. */
  234. explicit InvalidOperationError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  235. : LogicError(msg_, context_, "InvalidOperationError", errno_) {}
  236. /** Construct from message and errno value. */
  237. InvalidOperationError(const std::string &msg_, int errno_)
  238. : LogicError(msg_, "", "InvalidOperationError", errno_) {}
  239. protected:
  240. /** @private @internal
  241. * @brief Constructor for use by constructors of derived classes.
  242. */
  243. InvalidOperationError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  244. : LogicError(msg_, context_, type_, error_string_) {}
  245. /** @private @internal
  246. * @brief Constructor for use by constructors of derived classes.
  247. */
  248. InvalidOperationError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  249. : LogicError(msg_, context_, type_, errno_) {}
  250. };
  251. /** UnimplementedError indicates an attempt to use an unimplemented feature. */
  252. class XAPIAN_VISIBILITY_DEFAULT UnimplementedError : public LogicError {
  253. public:
  254. /** @private @internal
  255. * @brief Private constructor for use by remote backend.
  256. *
  257. * @param error_string_ Optional string describing error. May be NULL.
  258. */
  259. UnimplementedError(const std::string &msg_, const std::string &context_, const char * error_string_)
  260. : LogicError(msg_, context_, "UnimplementedError", error_string_) {}
  261. /** General purpose constructor which allows setting errno. */
  262. explicit UnimplementedError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  263. : LogicError(msg_, context_, "UnimplementedError", errno_) {}
  264. /** Construct from message and errno value. */
  265. UnimplementedError(const std::string &msg_, int errno_)
  266. : LogicError(msg_, "", "UnimplementedError", errno_) {}
  267. protected:
  268. /** @private @internal
  269. * @brief Constructor for use by constructors of derived classes.
  270. */
  271. UnimplementedError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  272. : LogicError(msg_, context_, type_, error_string_) {}
  273. /** @private @internal
  274. * @brief Constructor for use by constructors of derived classes.
  275. */
  276. UnimplementedError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  277. : LogicError(msg_, context_, type_, errno_) {}
  278. };
  279. /** DatabaseError indicates some sort of database related error. */
  280. class XAPIAN_VISIBILITY_DEFAULT DatabaseError : public RuntimeError {
  281. public:
  282. /** @private @internal
  283. * @brief Private constructor for use by remote backend.
  284. *
  285. * @param error_string_ Optional string describing error. May be NULL.
  286. */
  287. DatabaseError(const std::string &msg_, const std::string &context_, const char * error_string_)
  288. : RuntimeError(msg_, context_, "DatabaseError", error_string_) {}
  289. /** General purpose constructor which allows setting errno. */
  290. explicit DatabaseError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  291. : RuntimeError(msg_, context_, "DatabaseError", errno_) {}
  292. /** Construct from message and errno value. */
  293. DatabaseError(const std::string &msg_, int errno_)
  294. : RuntimeError(msg_, "", "DatabaseError", errno_) {}
  295. protected:
  296. /** @private @internal
  297. * @brief Constructor for use by constructors of derived classes.
  298. */
  299. DatabaseError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  300. : RuntimeError(msg_, context_, type_, error_string_) {}
  301. /** @private @internal
  302. * @brief Constructor for use by constructors of derived classes.
  303. */
  304. DatabaseError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  305. : RuntimeError(msg_, context_, type_, errno_) {}
  306. };
  307. /** DatabaseCorruptError indicates database corruption was detected. */
  308. class XAPIAN_VISIBILITY_DEFAULT DatabaseCorruptError : public DatabaseError {
  309. public:
  310. /** @private @internal
  311. * @brief Private constructor for use by remote backend.
  312. *
  313. * @param error_string_ Optional string describing error. May be NULL.
  314. */
  315. DatabaseCorruptError(const std::string &msg_, const std::string &context_, const char * error_string_)
  316. : DatabaseError(msg_, context_, "DatabaseCorruptError", error_string_) {}
  317. /** General purpose constructor which allows setting errno. */
  318. explicit DatabaseCorruptError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  319. : DatabaseError(msg_, context_, "DatabaseCorruptError", errno_) {}
  320. /** Construct from message and errno value. */
  321. DatabaseCorruptError(const std::string &msg_, int errno_)
  322. : DatabaseError(msg_, "", "DatabaseCorruptError", errno_) {}
  323. protected:
  324. /** @private @internal
  325. * @brief Constructor for use by constructors of derived classes.
  326. */
  327. DatabaseCorruptError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  328. : DatabaseError(msg_, context_, type_, error_string_) {}
  329. /** @private @internal
  330. * @brief Constructor for use by constructors of derived classes.
  331. */
  332. DatabaseCorruptError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  333. : DatabaseError(msg_, context_, type_, errno_) {}
  334. };
  335. /** DatabaseCreateError indicates a failure to create a database. */
  336. class XAPIAN_VISIBILITY_DEFAULT DatabaseCreateError : public DatabaseError {
  337. public:
  338. /** @private @internal
  339. * @brief Private constructor for use by remote backend.
  340. *
  341. * @param error_string_ Optional string describing error. May be NULL.
  342. */
  343. DatabaseCreateError(const std::string &msg_, const std::string &context_, const char * error_string_)
  344. : DatabaseError(msg_, context_, "DatabaseCreateError", error_string_) {}
  345. /** General purpose constructor which allows setting errno. */
  346. explicit DatabaseCreateError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  347. : DatabaseError(msg_, context_, "DatabaseCreateError", errno_) {}
  348. /** Construct from message and errno value. */
  349. DatabaseCreateError(const std::string &msg_, int errno_)
  350. : DatabaseError(msg_, "", "DatabaseCreateError", errno_) {}
  351. protected:
  352. /** @private @internal
  353. * @brief Constructor for use by constructors of derived classes.
  354. */
  355. DatabaseCreateError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  356. : DatabaseError(msg_, context_, type_, error_string_) {}
  357. /** @private @internal
  358. * @brief Constructor for use by constructors of derived classes.
  359. */
  360. DatabaseCreateError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  361. : DatabaseError(msg_, context_, type_, errno_) {}
  362. };
  363. /** DatabaseLockError indicates failure to lock a database. */
  364. class XAPIAN_VISIBILITY_DEFAULT DatabaseLockError : public DatabaseError {
  365. public:
  366. /** @private @internal
  367. * @brief Private constructor for use by remote backend.
  368. *
  369. * @param error_string_ Optional string describing error. May be NULL.
  370. */
  371. DatabaseLockError(const std::string &msg_, const std::string &context_, const char * error_string_)
  372. : DatabaseError(msg_, context_, "DatabaseLockError", error_string_) {}
  373. /** General purpose constructor which allows setting errno. */
  374. explicit DatabaseLockError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  375. : DatabaseError(msg_, context_, "DatabaseLockError", errno_) {}
  376. /** Construct from message and errno value. */
  377. DatabaseLockError(const std::string &msg_, int errno_)
  378. : DatabaseError(msg_, "", "DatabaseLockError", errno_) {}
  379. protected:
  380. /** @private @internal
  381. * @brief Constructor for use by constructors of derived classes.
  382. */
  383. DatabaseLockError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  384. : DatabaseError(msg_, context_, type_, error_string_) {}
  385. /** @private @internal
  386. * @brief Constructor for use by constructors of derived classes.
  387. */
  388. DatabaseLockError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  389. : DatabaseError(msg_, context_, type_, errno_) {}
  390. };
  391. /** DatabaseModifiedError indicates a database was modified.
  392. *
  393. * To recover after catching this error, you need to call
  394. * Xapian::Database::reopen() on the Database and repeat the operation
  395. * which failed.
  396. */
  397. class XAPIAN_VISIBILITY_DEFAULT DatabaseModifiedError : public DatabaseError {
  398. public:
  399. /** @private @internal
  400. * @brief Private constructor for use by remote backend.
  401. *
  402. * @param error_string_ Optional string describing error. May be NULL.
  403. */
  404. DatabaseModifiedError(const std::string &msg_, const std::string &context_, const char * error_string_)
  405. : DatabaseError(msg_, context_, "DatabaseModifiedError", error_string_) {}
  406. /** General purpose constructor which allows setting errno. */
  407. explicit DatabaseModifiedError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  408. : DatabaseError(msg_, context_, "DatabaseModifiedError", errno_) {}
  409. /** Construct from message and errno value. */
  410. DatabaseModifiedError(const std::string &msg_, int errno_)
  411. : DatabaseError(msg_, "", "DatabaseModifiedError", errno_) {}
  412. protected:
  413. /** @private @internal
  414. * @brief Constructor for use by constructors of derived classes.
  415. */
  416. DatabaseModifiedError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  417. : DatabaseError(msg_, context_, type_, error_string_) {}
  418. /** @private @internal
  419. * @brief Constructor for use by constructors of derived classes.
  420. */
  421. DatabaseModifiedError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  422. : DatabaseError(msg_, context_, type_, errno_) {}
  423. };
  424. /** DatabaseOpeningError indicates failure to open a database. */
  425. class XAPIAN_VISIBILITY_DEFAULT DatabaseOpeningError : public DatabaseError {
  426. public:
  427. /** @private @internal
  428. * @brief Private constructor for use by remote backend.
  429. *
  430. * @param error_string_ Optional string describing error. May be NULL.
  431. */
  432. DatabaseOpeningError(const std::string &msg_, const std::string &context_, const char * error_string_)
  433. : DatabaseError(msg_, context_, "DatabaseOpeningError", error_string_) {}
  434. /** General purpose constructor which allows setting errno. */
  435. explicit DatabaseOpeningError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  436. : DatabaseError(msg_, context_, "DatabaseOpeningError", errno_) {}
  437. /** Construct from message and errno value. */
  438. DatabaseOpeningError(const std::string &msg_, int errno_)
  439. : DatabaseError(msg_, "", "DatabaseOpeningError", errno_) {}
  440. protected:
  441. /** @private @internal
  442. * @brief Constructor for use by constructors of derived classes.
  443. */
  444. DatabaseOpeningError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  445. : DatabaseError(msg_, context_, type_, error_string_) {}
  446. /** @private @internal
  447. * @brief Constructor for use by constructors of derived classes.
  448. */
  449. DatabaseOpeningError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  450. : DatabaseError(msg_, context_, type_, errno_) {}
  451. };
  452. /** DatabaseVersionError indicates that a database is in an unsupported format.
  453. *
  454. * From time to time, new versions of Xapian will require the database format
  455. * to be changed, to allow new information to be stored or new optimisations
  456. * to be performed. Backwards compatibility will sometimes be maintained, so
  457. * that new versions of Xapian can open old databases, but in some cases
  458. * Xapian will be unable to open a database because it is in too old (or new)
  459. * a format. This can be resolved either be upgrading or downgrading the
  460. * version of Xapian in use, or by rebuilding the database from scratch with
  461. * the current version of Xapian.
  462. */
  463. class XAPIAN_VISIBILITY_DEFAULT DatabaseVersionError : public DatabaseOpeningError {
  464. public:
  465. /** @private @internal
  466. * @brief Private constructor for use by remote backend.
  467. *
  468. * @param error_string_ Optional string describing error. May be NULL.
  469. */
  470. DatabaseVersionError(const std::string &msg_, const std::string &context_, const char * error_string_)
  471. : DatabaseOpeningError(msg_, context_, "DatabaseVersionError", error_string_) {}
  472. /** General purpose constructor which allows setting errno. */
  473. explicit DatabaseVersionError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  474. : DatabaseOpeningError(msg_, context_, "DatabaseVersionError", errno_) {}
  475. /** Construct from message and errno value. */
  476. DatabaseVersionError(const std::string &msg_, int errno_)
  477. : DatabaseOpeningError(msg_, "", "DatabaseVersionError", errno_) {}
  478. protected:
  479. /** @private @internal
  480. * @brief Constructor for use by constructors of derived classes.
  481. */
  482. DatabaseVersionError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  483. : DatabaseOpeningError(msg_, context_, type_, error_string_) {}
  484. /** @private @internal
  485. * @brief Constructor for use by constructors of derived classes.
  486. */
  487. DatabaseVersionError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  488. : DatabaseOpeningError(msg_, context_, type_, errno_) {}
  489. };
  490. /** Indicates an attempt to access a document not present in the database. */
  491. class XAPIAN_VISIBILITY_DEFAULT DocNotFoundError : public RuntimeError {
  492. public:
  493. /** @private @internal
  494. * @brief Private constructor for use by remote backend.
  495. *
  496. * @param error_string_ Optional string describing error. May be NULL.
  497. */
  498. DocNotFoundError(const std::string &msg_, const std::string &context_, const char * error_string_)
  499. : RuntimeError(msg_, context_, "DocNotFoundError", error_string_) {}
  500. /** General purpose constructor which allows setting errno. */
  501. explicit DocNotFoundError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  502. : RuntimeError(msg_, context_, "DocNotFoundError", errno_) {}
  503. /** Construct from message and errno value. */
  504. DocNotFoundError(const std::string &msg_, int errno_)
  505. : RuntimeError(msg_, "", "DocNotFoundError", errno_) {}
  506. protected:
  507. /** @private @internal
  508. * @brief Constructor for use by constructors of derived classes.
  509. */
  510. DocNotFoundError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  511. : RuntimeError(msg_, context_, type_, error_string_) {}
  512. /** @private @internal
  513. * @brief Constructor for use by constructors of derived classes.
  514. */
  515. DocNotFoundError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  516. : RuntimeError(msg_, context_, type_, errno_) {}
  517. };
  518. /** Indicates an attempt to use a feature which is unavailable.
  519. *
  520. * Typically a feature is unavailable because it wasn't compiled in, or
  521. * because it requires other software or facilities which aren't available.
  522. */
  523. class XAPIAN_VISIBILITY_DEFAULT FeatureUnavailableError : public RuntimeError {
  524. public:
  525. /** @private @internal
  526. * @brief Private constructor for use by remote backend.
  527. *
  528. * @param error_string_ Optional string describing error. May be NULL.
  529. */
  530. FeatureUnavailableError(const std::string &msg_, const std::string &context_, const char * error_string_)
  531. : RuntimeError(msg_, context_, "FeatureUnavailableError", error_string_) {}
  532. /** General purpose constructor which allows setting errno. */
  533. explicit FeatureUnavailableError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  534. : RuntimeError(msg_, context_, "FeatureUnavailableError", errno_) {}
  535. /** Construct from message and errno value. */
  536. FeatureUnavailableError(const std::string &msg_, int errno_)
  537. : RuntimeError(msg_, "", "FeatureUnavailableError", errno_) {}
  538. protected:
  539. /** @private @internal
  540. * @brief Constructor for use by constructors of derived classes.
  541. */
  542. FeatureUnavailableError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  543. : RuntimeError(msg_, context_, type_, error_string_) {}
  544. /** @private @internal
  545. * @brief Constructor for use by constructors of derived classes.
  546. */
  547. FeatureUnavailableError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  548. : RuntimeError(msg_, context_, type_, errno_) {}
  549. };
  550. /** InternalError indicates a runtime problem of some sort. */
  551. class XAPIAN_VISIBILITY_DEFAULT InternalError : public RuntimeError {
  552. public:
  553. /** @private @internal
  554. * @brief Private constructor for use by remote backend.
  555. *
  556. * @param error_string_ Optional string describing error. May be NULL.
  557. */
  558. InternalError(const std::string &msg_, const std::string &context_, const char * error_string_)
  559. : RuntimeError(msg_, context_, "InternalError", error_string_) {}
  560. /** General purpose constructor which allows setting errno. */
  561. explicit InternalError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  562. : RuntimeError(msg_, context_, "InternalError", errno_) {}
  563. /** Construct from message and errno value. */
  564. InternalError(const std::string &msg_, int errno_)
  565. : RuntimeError(msg_, "", "InternalError", errno_) {}
  566. protected:
  567. /** @private @internal
  568. * @brief Constructor for use by constructors of derived classes.
  569. */
  570. InternalError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  571. : RuntimeError(msg_, context_, type_, error_string_) {}
  572. /** @private @internal
  573. * @brief Constructor for use by constructors of derived classes.
  574. */
  575. InternalError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  576. : RuntimeError(msg_, context_, type_, errno_) {}
  577. };
  578. /** Indicates a problem communicating with a remote database. */
  579. class XAPIAN_VISIBILITY_DEFAULT NetworkError : public RuntimeError {
  580. public:
  581. /** @private @internal
  582. * @brief Private constructor for use by remote backend.
  583. *
  584. * @param error_string_ Optional string describing error. May be NULL.
  585. */
  586. NetworkError(const std::string &msg_, const std::string &context_, const char * error_string_)
  587. : RuntimeError(msg_, context_, "NetworkError", error_string_) {}
  588. /** General purpose constructor which allows setting errno. */
  589. explicit NetworkError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  590. : RuntimeError(msg_, context_, "NetworkError", errno_) {}
  591. /** Construct from message and errno value. */
  592. NetworkError(const std::string &msg_, int errno_)
  593. : RuntimeError(msg_, "", "NetworkError", errno_) {}
  594. protected:
  595. /** @private @internal
  596. * @brief Constructor for use by constructors of derived classes.
  597. */
  598. NetworkError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  599. : RuntimeError(msg_, context_, type_, error_string_) {}
  600. /** @private @internal
  601. * @brief Constructor for use by constructors of derived classes.
  602. */
  603. NetworkError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  604. : RuntimeError(msg_, context_, type_, errno_) {}
  605. };
  606. /** Indicates a timeout expired while communicating with a remote database. */
  607. class XAPIAN_VISIBILITY_DEFAULT NetworkTimeoutError : public NetworkError {
  608. public:
  609. /** @private @internal
  610. * @brief Private constructor for use by remote backend.
  611. *
  612. * @param error_string_ Optional string describing error. May be NULL.
  613. */
  614. NetworkTimeoutError(const std::string &msg_, const std::string &context_, const char * error_string_)
  615. : NetworkError(msg_, context_, "NetworkTimeoutError", error_string_) {}
  616. /** General purpose constructor which allows setting errno. */
  617. explicit NetworkTimeoutError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  618. : NetworkError(msg_, context_, "NetworkTimeoutError", errno_) {}
  619. /** Construct from message and errno value. */
  620. NetworkTimeoutError(const std::string &msg_, int errno_)
  621. : NetworkError(msg_, "", "NetworkTimeoutError", errno_) {}
  622. protected:
  623. /** @private @internal
  624. * @brief Constructor for use by constructors of derived classes.
  625. */
  626. NetworkTimeoutError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  627. : NetworkError(msg_, context_, type_, error_string_) {}
  628. /** @private @internal
  629. * @brief Constructor for use by constructors of derived classes.
  630. */
  631. NetworkTimeoutError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  632. : NetworkError(msg_, context_, type_, errno_) {}
  633. };
  634. /** Indicates a query string can't be parsed. */
  635. class XAPIAN_VISIBILITY_DEFAULT QueryParserError : public RuntimeError {
  636. public:
  637. /** @private @internal
  638. * @brief Private constructor for use by remote backend.
  639. *
  640. * @param error_string_ Optional string describing error. May be NULL.
  641. */
  642. QueryParserError(const std::string &msg_, const std::string &context_, const char * error_string_)
  643. : RuntimeError(msg_, context_, "QueryParserError", error_string_) {}
  644. /** General purpose constructor which allows setting errno. */
  645. explicit QueryParserError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  646. : RuntimeError(msg_, context_, "QueryParserError", errno_) {}
  647. /** Construct from message and errno value. */
  648. QueryParserError(const std::string &msg_, int errno_)
  649. : RuntimeError(msg_, "", "QueryParserError", errno_) {}
  650. protected:
  651. /** @private @internal
  652. * @brief Constructor for use by constructors of derived classes.
  653. */
  654. QueryParserError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  655. : RuntimeError(msg_, context_, type_, error_string_) {}
  656. /** @private @internal
  657. * @brief Constructor for use by constructors of derived classes.
  658. */
  659. QueryParserError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  660. : RuntimeError(msg_, context_, type_, errno_) {}
  661. };
  662. /** RangeError indicates an attempt to access outside the bounds of a container.
  663. */
  664. class XAPIAN_VISIBILITY_DEFAULT RangeError : public RuntimeError {
  665. public:
  666. /** @private @internal
  667. * @brief Private constructor for use by remote backend.
  668. *
  669. * @param error_string_ Optional string describing error. May be NULL.
  670. */
  671. RangeError(const std::string &msg_, const std::string &context_, const char * error_string_)
  672. : RuntimeError(msg_, context_, "RangeError", error_string_) {}
  673. /** General purpose constructor which allows setting errno. */
  674. explicit RangeError(const std::string &msg_, const std::string &context_ = "", int errno_ = 0)
  675. : RuntimeError(msg_, context_, "RangeError", errno_) {}
  676. /** Construct from message and errno value. */
  677. RangeError(const std::string &msg_, int errno_)
  678. : RuntimeError(msg_, "", "RangeError", errno_) {}
  679. protected:
  680. /** @private @internal
  681. * @brief Constructor for use by constructors of derived classes.
  682. */
  683. RangeError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
  684. : RuntimeError(msg_, context_, type_, error_string_) {}
  685. /** @private @internal
  686. * @brief Constructor for use by constructors of derived classes.
  687. */
  688. RangeError(const std::string &msg_, const std::string &context_, const char * type_, int errno_)
  689. : RuntimeError(msg_, context_, type_, errno_) {}
  690. };
  691. }
  692. #endif /* XAPIAN_INCLUDED_ERROR_H */