Commit 22407c48 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2835] Throw a more appropriate exception

parent bc87d111
...@@ -101,10 +101,11 @@ public: ...@@ -101,10 +101,11 @@ public:
/// \brief Get the segment type /// \brief Get the segment type
/// ///
/// \throw isc::BadValue if called and state is SEGMENT_UNUSED. /// \throw isc::InvalidOperation if called and state is SEGMENT_UNUSED.
MemorySegmentType getSegmentType() const { MemorySegmentType getSegmentType() const {
if (getSegmentState() == SEGMENT_UNUSED) { if (getSegmentState() == SEGMENT_UNUSED) {
isc_throw(isc::BadValue, "No segment used, no type therefore."); isc_throw(isc::InvalidOperation,
"No segment used, no type therefore.");
} }
return (type_); return (type_);
} }
......
...@@ -576,7 +576,7 @@ TEST_F(ListTest, status) { ...@@ -576,7 +576,7 @@ TEST_F(ListTest, status) {
ASSERT_EQ(2, statuses.size()); ASSERT_EQ(2, statuses.size());
EXPECT_EQ("type1", statuses[0].getName()); EXPECT_EQ("type1", statuses[0].getName());
EXPECT_EQ(SEGMENT_UNUSED, statuses[0].getSegmentState()); EXPECT_EQ(SEGMENT_UNUSED, statuses[0].getSegmentState());
EXPECT_THROW(statuses[0].getSegmentType(), isc::BadValue); EXPECT_THROW(statuses[0].getSegmentType(), isc::InvalidOperation);
EXPECT_EQ("Test name", statuses[1].getName()); EXPECT_EQ("Test name", statuses[1].getName());
EXPECT_EQ(SEGMENT_INUSE, statuses[1].getSegmentState()); EXPECT_EQ(SEGMENT_INUSE, statuses[1].getSegmentState());
EXPECT_EQ(SEGMENT_LOCAL, statuses[1].getSegmentType()); EXPECT_EQ(SEGMENT_LOCAL, statuses[1].getSegmentType());
...@@ -1169,10 +1169,11 @@ TEST(DataSourceStatus, status) { ...@@ -1169,10 +1169,11 @@ TEST(DataSourceStatus, status) {
EXPECT_EQ("Test", status.getName()); EXPECT_EQ("Test", status.getName());
EXPECT_EQ(SEGMENT_INUSE, status.getSegmentState()); EXPECT_EQ(SEGMENT_INUSE, status.getSegmentState());
EXPECT_EQ(SEGMENT_LOCAL, status.getSegmentType()); EXPECT_EQ(SEGMENT_LOCAL, status.getSegmentType());
const DataSourceStatus statusUnused("Unused", SEGMENT_UNUSED, SEGMENT_FILE); const DataSourceStatus statusUnused("Unused", SEGMENT_UNUSED,
SEGMENT_FILE);
EXPECT_EQ("Unused", statusUnused.getName()); EXPECT_EQ("Unused", statusUnused.getName());
EXPECT_EQ(SEGMENT_UNUSED, statusUnused.getSegmentState()); EXPECT_EQ(SEGMENT_UNUSED, statusUnused.getSegmentState());
EXPECT_THROW(statusUnused.getSegmentType(), isc::BadValue); EXPECT_THROW(statusUnused.getSegmentType(), isc::InvalidOperation);
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment