1 // Copyright (C) 2010-2015 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 // XXX: we have another exceptions.h, so we need to use a prefix "DNS_" in
8 // the include guard.  More preferably, we should define a consistent naming
9 // style for the header guide (e.g. module-name_file-name_H) throughout the
10 // package.
11 
12 #ifndef DNS_EXCEPTIONS_H
13 #define DNS_EXCEPTIONS_H 1
14 
15 #include <exceptions/exceptions.h>
16 
17 namespace isc {
18 namespace dns {
19 
20 ///
21 /// \brief A standard DNS module exception ...[TBD]
22 ///
23 class Rcode;                    // forward declaration
24 
25 class Exception : public isc::Exception {
26 public:
Exception(const char * file,size_t line,const char * what)27     Exception(const char* file, size_t line, const char* what) :
28         isc::Exception(file, line, what) {}
29 };
30 
31 ///
32 /// \brief Base class for all sorts of text parse errors.
33 ///
34 class DNSTextError : public isc::dns::Exception {
35 public:
DNSTextError(const char * file,size_t line,const char * what)36     DNSTextError(const char* file, size_t line, const char* what) :
37         isc::dns::Exception(file, line, what) {}
38 };
39 
40 ///
41 /// \brief Base class for name parser exceptions.
42 ///
43 class NameParserException : public DNSTextError {
44 public:
NameParserException(const char * file,size_t line,const char * what)45     NameParserException(const char* file, size_t line, const char* what) :
46         DNSTextError(file, line, what) {}
47 };
48 
49 class DNSProtocolError : public isc::dns::Exception {
50 public:
DNSProtocolError(const char * file,size_t line,const char * what)51     DNSProtocolError(const char* file, size_t line, const char* what) :
52         isc::dns::Exception(file, line, what) {}
53     virtual const Rcode& getRcode() const = 0;
54 };
55 
56 class DNSMessageFORMERR : public DNSProtocolError {
57 public:
DNSMessageFORMERR(const char * file,size_t line,const char * what)58     DNSMessageFORMERR(const char* file, size_t line, const char* what) :
59         DNSProtocolError(file, line, what) {}
60     virtual const Rcode& getRcode() const;
61 };
62 
63 class DNSMessageBADVERS : public DNSProtocolError {
64 public:
DNSMessageBADVERS(const char * file,size_t line,const char * what)65     DNSMessageBADVERS(const char* file, size_t line, const char* what) :
66         DNSProtocolError(file, line, what) {}
67     virtual const Rcode& getRcode() const;
68 };
69 
70 }
71 }
72 #endif  // DNS_EXCEPTIONS_H
73 
74 // Local Variables:
75 // mode: c++
76 // End:
77