/// \brief Set IP version carrying the request.
/// \param ip_version IP version carrying the request
- /// \throw None
+ /// \throw isc::InvalidParameter ip_version is invalid
void setRequestIPVersion(const IPVersionType ip_version) {
- assert(ip_version != IP_VERSION_UNSPEC);
+ if (ip_version == IP_VERSION_UNSPEC) {
+ isc_throw(isc::InvalidParameter, "Invalid IP version");
+ }
req_ip_version_ = ip_version;
}
/// \brief Set transport protocol carrying the request.
/// \param transport_protocol Transport protocol carrying the request
- /// \throw None
+ /// \throw isc::InvalidParameter transport_protocol is invalid
void setRequestTransportProtocol(
const TransportProtocolType transport_protocol)
{
- assert(transport_protocol != TRANSPORT_UNSPEC);
+ if (transport_protocol == TRANSPORT_UNSPEC) {
+ isc_throw(isc::InvalidParameter, "Invalid transport protocol");
+ }
req_transport_protocol_ = transport_protocol;
}
TEST_F(CountersTest, invalidParameter) {
MessageAttributes msgattrs;
- // Passing *_UNSPEC should trigger an assertion failure.
- // Note that we just check that it dies - we don't check what message is
- // output.
- EXPECT_DEATH_IF_SUPPORTED(
+ // Passing *_UNSPEC should trigger throwing an exception
+ // isc::InvalidParameter.
+ EXPECT_THROW(
msgattrs.setRequestIPVersion(MessageAttributes::IP_VERSION_UNSPEC),
- ".*");
- EXPECT_DEATH_IF_SUPPORTED(
+ isc::InvalidParameter);
+ EXPECT_THROW(
msgattrs.setRequestTransportProtocol(
MessageAttributes::TRANSPORT_UNSPEC),
- ".*");
+ isc::InvalidParameter);
}
TEST_F(CountersTest, invalidOperationForGetRequestOpCode) {