Browse Source

[2421] Throw ZoneLoaderException even for MasterLoadError

Mukund Sivaraman 12 years ago
parent
commit
bc457a13e1

+ 2 - 5
src/lib/datasrc/client_list.cc

@@ -178,10 +178,7 @@ ConfigurableClientList::configure(const ConstElementPtr& config,
                         try {
                             cache->load(origin,
                                         paramConf->get(*it)->stringValue());
-                        } catch (const isc::dns::MasterLoadError& mle) {
-                            LOG_ERROR(logger, DATASRC_MASTERLOAD_ERROR)
-                                .arg(mle.what());
-                        } catch (const ZoneValidationException& e) {
+                        } catch (const ZoneLoaderException& e) {
                             LOG_ERROR(logger, DATASRC_LOAD_FROM_FILE_ERROR)
                                 .arg(e.what());
                         }
@@ -200,7 +197,7 @@ ConfigurableClientList::configure(const ConstElementPtr& config,
                         }
                         try {
                             cache->load(origin, *iterator);
-                        } catch (const ZoneValidationException& e) {
+                        } catch (const ZoneLoaderException& e) {
                             LOG_ERROR(logger, DATASRC_LOAD_FROM_ITERATOR_ERROR)
                                 .arg(e.what());
                         }

+ 0 - 5
src/lib/datasrc/datasrc_messages.mes

@@ -305,11 +305,6 @@ Therefore, the zone will not be available for this process. If this is
 a problem, you should move the zone to some database backend (sqlite3, for
 example) and use it from there.
 
-% DATASRC_MASTERLOAD_ERROR %1
-An error was found in the zone data for a MasterFiles zone. The zone
-is not loaded. The specific error is shown in the message, and should
-be addressed.
-
 % DATASRC_LOAD_FROM_FILE_ERROR %1
 An error was found in the zone data when it was being loaded from a
 file. The zone was not loaded. The specific error is shown in the

+ 2 - 2
src/lib/datasrc/exceptions.h

@@ -31,8 +31,8 @@ struct ZoneException : public Exception {
 /// 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) :
+struct ZoneLoaderException : public ZoneException {
+    ZoneLoaderException(const char* file, size_t line, const char* what) :
         ZoneException(file, line, what)
     {}
 };

+ 5 - 1
src/lib/datasrc/memory/zone_data_loader.cc

@@ -207,7 +207,11 @@ void
 masterLoadWrapper(const char* const filename, const Name& origin,
                   const RRClass& zone_class, LoadCallback callback)
 {
-    masterLoad(filename, origin, zone_class, boost::bind(callback, _1));
+    try {
+        masterLoad(filename, origin, zone_class, boost::bind(callback, _1));
+    } catch (MasterLoadError& e) {
+        isc_throw(ZoneLoaderException, e.what());
+    }
 }
 
 // The installer called from the iterator version of loadZoneData().

+ 2 - 2
src/lib/datasrc/memory/zone_data_loader.h

@@ -30,9 +30,9 @@ namespace memory {
 ///
 /// This is thrown if an empty zone would be created during
 /// \c loadZoneData().
-struct EmptyZone : public ZoneValidationException {
+struct EmptyZone : public ZoneLoaderException {
     EmptyZone(const char* file, size_t line, const char* what) :
-        ZoneValidationException(file, line, what)
+        ZoneLoaderException(file, line, what)
     {}
 };
 

+ 2 - 2
src/lib/datasrc/memory/zone_data_updater.h

@@ -95,9 +95,9 @@ public:
     ///
     /// This is thrown against general error cases in adding an RRset
     /// to the zone.
-    struct AddError : public ZoneValidationException {
+    struct AddError : public ZoneLoaderException {
         AddError(const char* file, size_t line, const char* what) :
-            ZoneValidationException(file, line, what)
+            ZoneLoaderException(file, line, what)
         {}
     };
 

+ 5 - 5
src/lib/datasrc/tests/memory/memory_client_unittest.cc

@@ -186,7 +186,7 @@ TEST_F(MemoryClientTest, loadRRsetDoesntMatchOrigin) {
     // in an exception.
     EXPECT_THROW(client_->load(Name("example.com"),
                                TEST_DATA_DIR "/example.org-empty.zone"),
-                 MasterLoadError);
+                 ZoneLoaderException);
 }
 
 TEST_F(MemoryClientTest, loadErrorsInParsingZoneMustNotLeak1) {
@@ -195,7 +195,7 @@ TEST_F(MemoryClientTest, loadErrorsInParsingZoneMustNotLeak1) {
     // allocations.
     EXPECT_THROW(client_->load(Name("example.org"),
                                TEST_DATA_DIR "/example.org-broken1.zone"),
-                 MasterLoadError);
+                 ZoneLoaderException);
     // Teardown checks for memory segment leaks
 }
 
@@ -205,14 +205,14 @@ TEST_F(MemoryClientTest, loadErrorsInParsingZoneMustNotLeak2) {
     // allocations.
     EXPECT_THROW(client_->load(Name("example.org"),
                                TEST_DATA_DIR "/example.org-broken2.zone"),
-                 MasterLoadError);
+                 ZoneLoaderException);
     // Teardown checks for memory segment leaks
 }
 
 TEST_F(MemoryClientTest, loadNonExistentZoneFile) {
     EXPECT_THROW(client_->load(Name("example.org"),
                                TEST_DATA_DIR "/somerandomfilename"),
-                 MasterLoadError);
+                 ZoneLoaderException);
     // Teardown checks for memory segment leaks
 }
 
@@ -478,7 +478,7 @@ TEST_F(MemoryClientTest, loadOutOfZoneThrows) {
     EXPECT_THROW(client_->load(Name("example.org"),
                                TEST_DATA_DIR
                                "/example.org-out-of-zone.zone"),
-                 MasterLoadError);
+                 ZoneLoaderException);
     // Teardown checks for memory segment leaks
 }