/// 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.
/// 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;
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;
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_));
/// 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();
/// 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();
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
// 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());
// 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_);
}
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
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
// 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());