From: Mukund Sivaraman Date: Wed, 14 Nov 2012 06:49:43 +0000 (+0530) Subject: [2421] Add zone exceptions hierarchy X-Git-Tag: trac2487_base~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c30834cb78baa51e6776452069ceda87d34864c;p=thirdparty%2Fkea.git [2421] Add zone exceptions hierarchy --- diff --git a/src/lib/datasrc/Makefile.am b/src/lib/datasrc/Makefile.am index eccc147a77..f24d62c9c9 100644 --- a/src/lib/datasrc/Makefile.am +++ b/src/lib/datasrc/Makefile.am @@ -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 index 0000000000..12924ea66f --- /dev/null +++ b/src/lib/datasrc/exceptions.h @@ -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 + +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: diff --git a/src/lib/datasrc/memory/zone_data_loader.h b/src/lib/datasrc/memory/zone_data_loader.h index 6f02fcbce8..d2470a7c5c 100644 --- a/src/lib/datasrc/memory/zone_data_loader.h +++ b/src/lib/datasrc/memory/zone_data_loader.h @@ -15,6 +15,7 @@ #ifndef DATASRC_ZONE_DATA_LOADER_H #define DATASRC_ZONE_DATA_LOADER_H 1 +#include #include #include #include @@ -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) {} }; diff --git a/src/lib/datasrc/memory/zone_data_updater.h b/src/lib/datasrc/memory/zone_data_updater.h index 341d8ae6ce..135845a0b6 100644 --- a/src/lib/datasrc/memory/zone_data_updater.h +++ b/src/lib/datasrc/memory/zone_data_updater.h @@ -15,6 +15,7 @@ #ifndef DATASRC_ZONE_DATA_UPDATER_H #define DATASRC_ZONE_DATA_UPDATER_H 1 +#include #include #include #include @@ -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) {} }; diff --git a/src/lib/datasrc/zone.h b/src/lib/datasrc/zone.h index 9572ed09b5..0d7438daa5 100644 --- a/src/lib/datasrc/zone.h +++ b/src/lib/datasrc/zone.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -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