exceptions.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef DATASRC_EXCEPTIONS_H
  15. #define DATASRC_EXCEPTIONS_H 1
  16. #include <exceptions/exceptions.h>
  17. namespace isc {
  18. namespace datasrc {
  19. /// \brief Top level exception related to data source.
  20. ///
  21. /// This exception is the most generic form of exception for errors or
  22. /// unexpected events that can happen in the data source module. In general,
  23. /// if an application needs to catch these conditions explicitly, it should
  24. /// catch more specific exceptions derived from this class; the severity
  25. /// of the conditions will vary very much, and such an application would
  26. /// normally like to behave differently depending on the severity.
  27. class DataSourceError : public Exception {
  28. public:
  29. DataSourceError(const char* file, size_t line, const char* what) :
  30. isc::Exception(file, line, what) {}
  31. };
  32. /// \brief No such serial number when obtaining difference iterator
  33. ///
  34. /// Thrown if either the zone/start serial number or zone/end serial number
  35. /// combination does not exist in the differences table. (Note that this
  36. /// includes the case where the differences table contains no records related
  37. /// to that zone.)
  38. class NoSuchSerial : public DataSourceError {
  39. public:
  40. NoSuchSerial(const char* file, size_t line, const char* what) :
  41. DataSourceError(file, line, what) {}
  42. };
  43. /// \brief A specified zone does not exist in the specified data source.
  44. ///
  45. /// This exception is thrown from methods that take a zone name and perform
  46. /// some action regarding that zone on the corresponding data source.
  47. class NoSuchZone : public DataSourceError {
  48. public:
  49. NoSuchZone(const char* file, size_t line, const char* what) :
  50. DataSourceError(file, line, what) {}
  51. };
  52. /// \brief An error indicating a zone is recognized but its content is not
  53. /// available.
  54. ///
  55. /// This generally indicates a condition that there's an error in the zone
  56. /// content and it's not successfully loaded.
  57. class EmptyZone : public DataSourceError {
  58. public:
  59. EmptyZone(const char* file, size_t line, const char* what) :
  60. DataSourceError(file, line, what) {}
  61. };
  62. /// Base class for a number of exceptions that are thrown while working
  63. /// with zones.
  64. struct ZoneException : public Exception {
  65. ZoneException(const char* file, size_t line, const char* what) :
  66. Exception(file, line, what)
  67. {}
  68. };
  69. /// Base class for a number of exceptions that are thrown when zones are
  70. /// being loaded. This is a recoverable exception. It should be possible
  71. /// to skip the bad zone and continue loading/serving other zones.
  72. struct ZoneLoaderException : public ZoneException {
  73. ZoneLoaderException(const char* file, size_t line, const char* what) :
  74. ZoneException(file, line, what)
  75. {}
  76. };
  77. } // namespace datasrc
  78. } // namespace isc
  79. #endif // DATASRC_EXCEPTIONS
  80. // Local Variables:
  81. // mode: c++
  82. // End: