]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2421] Add zone exceptions hierarchy
authorMukund Sivaraman <muks@isc.org>
Wed, 14 Nov 2012 06:49:43 +0000 (12:19 +0530)
committerMukund Sivaraman <muks@isc.org>
Wed, 14 Nov 2012 06:49:43 +0000 (12:19 +0530)
src/lib/datasrc/Makefile.am
src/lib/datasrc/exceptions.h [new file with mode: 0644]
src/lib/datasrc/memory/zone_data_loader.h
src/lib/datasrc/memory/zone_data_updater.h
src/lib/datasrc/zone.h

index eccc147a773e0e1ab81d571c83a732830fd62a24..f24d62c9c9828ee9016947539612b5e91d6a9584 100644 (file)
@@ -26,6 +26,7 @@ lib_LTLIBRARIES = libb10-datasrc.la
 libb10_datasrc_la_SOURCES = data_source.h
 libb10_datasrc_la_SOURCES += rbnode_rrset.h
 libb10_datasrc_la_SOURCES += rbtree.h
+libb10_datasrc_la_SOURCES += exceptions.h
 libb10_datasrc_la_SOURCES += zonetable.h zonetable.cc
 libb10_datasrc_la_SOURCES += zone.h zone_finder.cc zone_finder_context.cc
 libb10_datasrc_la_SOURCES += result.h
diff --git a/src/lib/datasrc/exceptions.h b/src/lib/datasrc/exceptions.h
new file mode 100644 (file)
index 0000000..12924ea
--- /dev/null
@@ -0,0 +1,47 @@
+// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef DATASRC_EXCEPTIONS_H
+#define DATASRC_EXCEPTIONS_H 1
+
+#include <exceptions/exceptions.h>
+
+namespace isc {
+namespace datasrc {
+
+/// Base class for a number of exceptions that are thrown while working
+/// with zones.
+struct ZoneException : public Exception {
+    ZoneException(const char* file, size_t line, const char* what) :
+        Exception(file, line, what)
+    {}
+};
+
+/// Base class for a number of exceptions that are thrown when zones are
+/// being loaded. This is a recoverable exception. It should be possible
+/// to skip the bad zone and continue loading/serving other zones.
+struct ZoneValidationException : public ZoneException {
+    ZoneValidationException(const char* file, size_t line, const char* what) :
+        ZoneException(file, line, what)
+    {}
+};
+
+} // namespace datasrc
+} // namespace isc
+
+#endif // DATASRC_EXCEPTIONS
+
+// Local Variables:
+// mode: c++
+// End:
index 6f02fcbce8cb0ba2725acaed42562d9e09019e5f..d2470a7c5c5e56225f49072d92d0657f10afca8d 100644 (file)
@@ -15,6 +15,7 @@
 #ifndef DATASRC_ZONE_DATA_LOADER_H
 #define DATASRC_ZONE_DATA_LOADER_H 1
 
+#include <datasrc/exceptions.h>
 #include <datasrc/memory/zone_data.h>
 #include <datasrc/iterator.h>
 #include <dns/name.h>
@@ -29,9 +30,9 @@ namespace memory {
 ///
 /// This is thrown if an empty zone would be created during
 /// \c loadZoneData().
-struct EmptyZone : public InvalidParameter {
+struct EmptyZone : public ZoneValidationException {
     EmptyZone(const char* file, size_t line, const char* what) :
-        InvalidParameter(file, line, what)
+        ZoneValidationException(file, line, what)
     {}
 };
 
index 341d8ae6ce658c1aca4e8fd145446b4e23d18272..135845a0b6c3eb64383a4c9398900dd9e4a2df3f 100644 (file)
@@ -15,6 +15,7 @@
 #ifndef DATASRC_ZONE_DATA_UPDATER_H
 #define DATASRC_ZONE_DATA_UPDATER_H 1
 
+#include <datasrc/exceptions.h>
 #include <datasrc/memory/zone_data.h>
 #include <datasrc/memory/rdata_serialization.h>
 #include <dns/name.h>
@@ -94,14 +95,9 @@ public:
     ///
     /// This is thrown against general error cases in adding an RRset
     /// to the zone.
-    ///
-    /// Note: this exception would cover cases for \c OutOfZone or
-    /// \c NullRRset.  We'll need to clarify and unify the granularity
-    /// of exceptions eventually.  For now, exceptions are added as
-    /// developers see the need for it.
-    struct AddError : public InvalidParameter {
+    struct AddError : public ZoneValidationException {
         AddError(const char* file, size_t line, const char* what) :
-            InvalidParameter(file, line, what)
+            ZoneValidationException(file, line, what)
         {}
     };
 
index 9572ed09b5895474bd8ed52d891e3eb8c3b80e0e..0d7438daa5892cd9e714d799a0f41800b45d9122 100644 (file)
@@ -19,6 +19,7 @@
 #include <dns/rrset.h>
 #include <dns/rrtype.h>
 
+#include <datasrc/exceptions.h>
 #include <datasrc/result.h>
 
 #include <utility>
@@ -31,10 +32,10 @@ namespace datasrc {
 ///
 /// This is thrown when a method is called for a name or RRset which
 /// is not in or below the zone.
-class OutOfZone : public Exception {
+class OutOfZone : public ZoneException {
 public:
     OutOfZone(const char* file, size_t line, const char* what) :
-        isc::Exception(file, line, what) {}
+        ZoneException(file, line, what) {}
 };
 
 /// \brief The base class to search a zone for RRsets