BIND 10 trac2207, updated. ccfb2bf2c5226f21e793df4abaa9b98a993b6eb3 [2207] Throw better exception
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Oct 17 11:00:13 UTC 2012
The branch, trac2207 has been updated
via ccfb2bf2c5226f21e793df4abaa9b98a993b6eb3 (commit)
from 4601f7ef87135a559b4fa7a1daaf2f1de8f040c3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ccfb2bf2c5226f21e793df4abaa9b98a993b6eb3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Oct 17 12:59:23 2012 +0200
[2207] Throw better exception
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/memory/zone_writer.h | 4 ++--
src/lib/datasrc/memory/zone_writer_local.cc | 8 ++++----
src/lib/datasrc/memory/zone_writer_local.h | 4 ++--
.../datasrc/tests/memory/zone_writer_unittest.cc | 18 +++++++++---------
4 files changed, 17 insertions(+), 17 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/zone_writer.h b/src/lib/datasrc/memory/zone_writer.h
index 1fdfbfd..6671429 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 0bccdc1..44ff03c 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 c0f51ed..a106079 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 dea093b..bffcde5 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());
More information about the bind10-changes
mailing list