diff --git a/src/lib/datasrc/memory/zone_writer.h b/src/lib/datasrc/memory/zone_writer.h index 1fdfbfd643..6671429ba5 100644 --- a/src/lib/datasrc/memory/zone_writer.h +++ b/src/lib/datasrc/memory/zone_writer.h @@ -47,7 +47,7 @@ public: /// discard it. /// \note After successful load(), you have to call cleanup() some time /// later. - /// \throw isc::Unexpected if called second time. + /// \throw isc::InvalidOperation if called second time. virtual void load() = 0; /// \brief Put the changes to effect. @@ -63,7 +63,7 @@ public: /// This may throw in rare cases, depending on the concrete implementation. /// If it throws, you still need to call cleanup(). /// - /// \throw isc::Unexpected if called without previous load() or for the + /// \throw isc::InvalidOperation if called without previous load() or for the /// second time or cleanup() was called already. virtual void install() = 0; diff --git a/src/lib/datasrc/memory/zone_writer_local.cc b/src/lib/datasrc/memory/zone_writer_local.cc index 0bccdc1560..44ff03cb5c 100644 --- a/src/lib/datasrc/memory/zone_writer_local.cc +++ b/src/lib/datasrc/memory/zone_writer_local.cc @@ -46,14 +46,14 @@ ZoneWriterLocal::~ZoneWriterLocal() { void ZoneWriterLocal::load() { if (loaded_) { - isc_throw(isc::Unexpected, "Trying to load twice"); + isc_throw(isc::InvalidOperation, "Trying to load twice"); } zone_data_ = load_action_(segment_->getMemorySegment()); if (zone_data_ == NULL) { // Bug inside load_action_. - isc_throw(isc::Unexpected, "No data returned from load action"); + isc_throw(isc::InvalidOperation, "No data returned from load action"); } loaded_ = true; @@ -63,13 +63,13 @@ ZoneWriterLocal::load() { void ZoneWriterLocal::install() { if (!data_ready_) { - isc_throw(isc::Unexpected, "No data to install"); + isc_throw(isc::InvalidOperation, "No data to install"); } ZoneTable* table(segment_->getHeader().getTable()); if (table == NULL) { - isc_throw(isc::Unexpected, "No zone table present"); + isc_throw(isc::InvalidOperation, "No zone table present"); } ZoneTable::AddResult result(table->addZone(segment_->getMemorySegment(), rrclass_, origin_, zone_data_)); diff --git a/src/lib/datasrc/memory/zone_writer_local.h b/src/lib/datasrc/memory/zone_writer_local.h index c0f51ed045..a106079465 100644 --- a/src/lib/datasrc/memory/zone_writer_local.h +++ b/src/lib/datasrc/memory/zone_writer_local.h @@ -53,7 +53,7 @@ public: /// This calls the load_action (passed to constructor) and stores the /// data for future use. /// - /// \throw isc::Unexpected if it is called the second time in lifetime + /// \throw isc::InvalidOperation if it is called the second time in lifetime /// of the object. /// \throw Whatever the load_action throws, it is propagated up. virtual void load(); @@ -63,7 +63,7 @@ public: /// It modifies the zone table accessible through the segment (passed to /// constructor). /// - /// \throw isc::Unexpected if it is called the second time in lifetime + /// \throw isc::InvalidOperation if it is called the second time in lifetime /// of the object or if load() was not called previously or if /// cleanup() was already called. virtual void install(); diff --git a/src/lib/datasrc/tests/memory/zone_writer_unittest.cc b/src/lib/datasrc/tests/memory/zone_writer_unittest.cc index dea093b8e3..bffcde5585 100644 --- a/src/lib/datasrc/tests/memory/zone_writer_unittest.cc +++ b/src/lib/datasrc/tests/memory/zone_writer_unittest.cc @@ -118,7 +118,7 @@ TEST_F(ZoneWriterLocalTest, loadTwice) { load_called_ = false; // The second time, it should not be possible - EXPECT_THROW(writer_->load(), isc::Unexpected); + EXPECT_THROW(writer_->load(), isc::InvalidOperation); EXPECT_FALSE(load_called_); // The object should not be damaged, try installing and clearing now @@ -139,20 +139,20 @@ TEST_F(ZoneWriterLocalTest, loadLater) { // Reset so we see nothing is called now load_called_ = false; - EXPECT_THROW(writer_->load(), isc::Unexpected); + EXPECT_THROW(writer_->load(), isc::InvalidOperation); EXPECT_FALSE(load_called_); // Cleanup and try loading again. Still shouldn't work. EXPECT_NO_THROW(writer_->cleanup()); - EXPECT_THROW(writer_->load(), isc::Unexpected); + EXPECT_THROW(writer_->load(), isc::InvalidOperation); EXPECT_FALSE(load_called_); } // Try calling install at various bad times TEST_F(ZoneWriterLocalTest, invalidInstall) { // Nothing loaded yet - EXPECT_THROW(writer_->install(), isc::Unexpected); + EXPECT_THROW(writer_->install(), isc::InvalidOperation); EXPECT_FALSE(load_called_); EXPECT_NO_THROW(writer_->load()); @@ -160,7 +160,7 @@ TEST_F(ZoneWriterLocalTest, invalidInstall) { // This install is OK EXPECT_NO_THROW(writer_->install()); // But we can't call it second time now - EXPECT_THROW(writer_->install(), isc::Unexpected); + EXPECT_THROW(writer_->install(), isc::InvalidOperation); EXPECT_FALSE(load_called_); } @@ -174,7 +174,7 @@ TEST_F(ZoneWriterLocalTest, cleanWithoutInstall) { EXPECT_TRUE(load_called_); // We cleaned up, no way to install now - EXPECT_THROW(writer_->install(), isc::Unexpected); + EXPECT_THROW(writer_->install(), isc::InvalidOperation); } // Test the case when load callback throws @@ -183,7 +183,7 @@ TEST_F(ZoneWriterLocalTest, loadThrows) { EXPECT_THROW(writer_->load(), TestException); // We can't install now - EXPECT_THROW(writer_->install(), isc::Unexpected); + EXPECT_THROW(writer_->install(), isc::InvalidOperation); EXPECT_TRUE(load_called_); // But we can cleanup @@ -208,10 +208,10 @@ TEST_F(ZoneWriterLocalTest, retry) { // Check the writer defends itsefl when load action returns NULL TEST_F(ZoneWriterLocalTest, loadNull) { load_null_ = true; - EXPECT_THROW(writer_->load(), isc::Unexpected); + EXPECT_THROW(writer_->load(), isc::InvalidOperation); // We can't install that - EXPECT_THROW(writer_->install(), isc::Unexpected); + EXPECT_THROW(writer_->install(), isc::InvalidOperation); // It should be possible to clean up safely EXPECT_NO_THROW(writer_->cleanup());