exceptions.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (C) 2010 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. // XXX: we have another exceptions.h, so we need to use a prefix "DNS_" in
  15. // the include guard. More preferably, we should define a consistent naming
  16. // style for the header guide (e.g. module-name_file-name_H) throughout the
  17. // package.
  18. #ifndef __DNS_EXCEPTIONS_H
  19. #define __DNS_EXCEPTIONS_H 1
  20. #include <exceptions/exceptions.h>
  21. namespace isc {
  22. namespace dns {
  23. ///
  24. /// \brief A standard DNS module exception ...[TBD]
  25. ///
  26. class Rcode; // forward declaration
  27. class DNSProtocolError : public isc::Exception {
  28. public:
  29. DNSProtocolError(const char* file, size_t line, const char* what) :
  30. isc::Exception(file, line, what) {}
  31. virtual const Rcode& getRcode() const = 0;
  32. };
  33. class DNSMessageFORMERR : public DNSProtocolError {
  34. public:
  35. DNSMessageFORMERR(const char* file, size_t line, const char* what) :
  36. DNSProtocolError(file, line, what) {}
  37. virtual const Rcode& getRcode() const;
  38. };
  39. class DNSMessageBADVERS : public DNSProtocolError {
  40. public:
  41. DNSMessageBADVERS(const char* file, size_t line, const char* what) :
  42. DNSProtocolError(file, line, what) {}
  43. virtual const Rcode& getRcode() const;
  44. };
  45. }
  46. }
  47. #endif // __DNS_EXCEPTIONS_H
  48. // Local Variables:
  49. // mode: c++
  50. // End: