Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
22407c48
Commit
22407c48
authored
Mar 22, 2013
by
Michal 'vorner' Vaner
Browse files
[2835] Throw a more appropriate exception
parent
bc87d111
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/client_list.h
View file @
22407c48
...
...
@@ -101,10 +101,11 @@ public:
/// \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
{
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_
);
}
...
...
src/lib/datasrc/tests/client_list_unittest.cc
View file @
22407c48
...
...
@@ -576,7 +576,7 @@ TEST_F(ListTest, status) {
ASSERT_EQ
(
2
,
statuses
.
size
());
EXPECT_EQ
(
"type1"
,
statuses
[
0
].
getName
());
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
(
SEGMENT_INUSE
,
statuses
[
1
].
getSegmentState
());
EXPECT_EQ
(
SEGMENT_LOCAL
,
statuses
[
1
].
getSegmentType
());
...
...
@@ -1169,10 +1169,11 @@ TEST(DataSourceStatus, status) {
EXPECT_EQ
(
"Test"
,
status
.
getName
());
EXPECT_EQ
(
SEGMENT_INUSE
,
status
.
getSegmentState
());
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
(
SEGMENT_UNUSED
,
statusUnused
.
getSegmentState
());
EXPECT_THROW
(
statusUnused
.
getSegmentType
(),
isc
::
BadValue
);
EXPECT_THROW
(
statusUnused
.
getSegmentType
(),
isc
::
InvalidOperation
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment