1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (C) 2010-2024 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// XXX: we have another exceptions.h, so we need to use a prefix "DNS_" in
// the include guard.  More preferably, we should define a consistent naming
// style for the header guide (e.g. module-name_file-name_H) throughout the
// package.

#ifndef DNS_EXCEPTIONS_H
#define DNS_EXCEPTIONS_H

#include <exceptions/exceptions.h>

namespace isc {
namespace dns {

///
/// \brief A standard DNS module exception ...[TBD]
///
class Rcode;                    // forward declaration

class Exception : public isc::Exception {
public:
    Exception(const char* file, size_t line, const char* what) :
        isc::Exception(file, line, what) {}
};

///
/// \brief Base class for all sorts of text parse errors.
///
class DNSTextError : public isc::dns::Exception {
public:
    DNSTextError(const char* file, size_t line, const char* what) :
        isc::dns::Exception(file, line, what) {}
};

///
/// \brief Base class for name parser exceptions.
///
class NameParserException : public DNSTextError {
public:
    NameParserException(const char* file, size_t line, const char* what) :
        DNSTextError(file, line, what) {}
};

class DNSProtocolError : public isc::dns::Exception {
public:
    DNSProtocolError(const char* file, size_t line, const char* what) :
        isc::dns::Exception(file, line, what) {}
    virtual const Rcode& getRcode() const = 0;<--- Virtual function in base class<--- Virtual function in base class
};

class DNSMessageFORMERR : public DNSProtocolError {
public:
    DNSMessageFORMERR(const char* file, size_t line, const char* what) :
        DNSProtocolError(file, line, what) {}
    virtual const Rcode& getRcode() const;<--- Function in derived class
};

class DNSMessageBADVERS : public DNSProtocolError {
public:
    DNSMessageBADVERS(const char* file, size_t line, const char* what) :
        DNSProtocolError(file, line, what) {}
    virtual const Rcode& getRcode() const;<--- Function in derived class
};

}
}
#endif  // DNS_EXCEPTIONS_H