PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

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

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