]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2421] Handle exceptions when loading a zone
authorMukund Sivaraman <muks@isc.org>
Wed, 7 Nov 2012 19:47:42 +0000 (01:17 +0530)
committerMukund Sivaraman <muks@isc.org>
Wed, 7 Nov 2012 19:49:50 +0000 (01:19 +0530)
src/lib/datasrc/client_list.cc
src/lib/datasrc/datasrc_messages.mes

index e7fb63b9dc0222d0e0f34956968bde4b80296a91..19ec3c36fb1151d6b4cfad270e923fee26c5fa07 100644 (file)
@@ -20,6 +20,7 @@
 #include "memory/zone_table_segment.h"
 #include "memory/zone_writer.h"
 #include "memory/zone_data_loader.h"
+#include "memory/zone_data_updater.h"
 #include "logger.h"
 #include <dns/masterload.h>
 #include <util/memory_segment_local.h>
@@ -37,6 +38,7 @@ using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using isc::datasrc::memory::InMemoryClient;
 using isc::datasrc::memory::ZoneTableSegment;
+using isc::datasrc::memory::ZoneDataUpdater;
 
 namespace isc {
 namespace datasrc {
@@ -178,6 +180,15 @@ ConfigurableClientList::configure(const ConstElementPtr& config,
                         } catch (const isc::dns::MasterLoadError& mle) {
                             LOG_ERROR(logger, DATASRC_MASTERLOAD_ERROR)
                                 .arg(mle.what());
+                        } catch (const ZoneDataUpdater::NullRRset& e) {
+                            LOG_ERROR(logger, DATASRC_LOAD_NULL_RRSET_ERROR)
+                                .arg(e.what());
+                        } catch (const ZoneDataUpdater::AddError& e) {
+                            LOG_ERROR(logger, DATASRC_LOAD_ADD_ERROR)
+                                .arg(e.what());
+                        } catch (const isc::datasrc::memory::EmptyZone& e) {
+                            LOG_ERROR(logger, DATASRC_LOAD_EMPTY_ZONE_ERROR)
+                                .arg(e.what());
                         }
                     } else {
                         ZoneIteratorPtr iterator;
@@ -192,7 +203,21 @@ ConfigurableClientList::configure(const ConstElementPtr& config,
                             isc_throw(isc::Unexpected, "Got NULL iterator "
                                       "for zone " << origin);
                         }
-                        cache->load(origin, *iterator);
+                        try {
+                            cache->load(origin, *iterator);
+                        } catch (const isc::dns::MasterLoadError& mle) {
+                            LOG_ERROR(logger, DATASRC_MASTERLOAD_ERROR)
+                                .arg(mle.what());
+                        } catch (const ZoneDataUpdater::NullRRset& e) {
+                            LOG_ERROR(logger, DATASRC_LOAD_NULL_RRSET_ERROR)
+                                .arg(e.what());
+                        } catch (const ZoneDataUpdater::AddError& e) {
+                            LOG_ERROR(logger, DATASRC_LOAD_ADD_ERROR)
+                                .arg(e.what());
+                        } catch (const isc::datasrc::memory::EmptyZone& e) {
+                            LOG_ERROR(logger, DATASRC_LOAD_EMPTY_ZONE_ERROR)
+                                .arg(e.what());
+                        }
                     }
                 }
             }
index 94b4d4249e12dddd750a7a63b72503ca4d82cc33..3788a48557e6ca9b8ca047fb08eecafbe2439e12 100644 (file)
@@ -310,6 +310,21 @@ 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_ADD_ERROR %1
+An error was found in the zone data when it was being loaded. The zone
+was not loaded. The specific error is shown in the message, and should
+be addressed.
+
+% DATASRC_LOAD_NULL_RRSET_ERROR %1
+A NULL RRset was passed to be added to a zone. The zone was not
+loaded. The specific error is shown in the message, and should be
+addressed.
+
+% DATASRC_LOAD_EMPTY_ZONE_ERROR %1
+A zone was asked to be loaded without any zone data. The zone was not
+loaded. The specific error is shown in the message, and should be
+addressed.
+
 % DATASRC_MEM_ADD_RRSET adding RRset '%1/%2' into zone '%3'
 Debug information. An RRset is being added to the in-memory data source.