2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-03 07:25:18 +00:00

[#92,!13] Moved NoSuchLease exception back to dhcpsrv library.

This commit is contained in:
Marcin Siodelski
2018-08-29 14:14:57 +02:00
parent cc98fc37da
commit 4255e8fcc0
10 changed files with 43 additions and 15 deletions

View File

@@ -31,13 +31,6 @@ public:
isc::Exception(file, line, what) {}
};
/// @brief Attempt to update lease that was not there
class NoSuchLease : public Exception {
public:
NoSuchLease(const char* file, size_t line, const char* what) :
isc::Exception(file, line, what) {}
};
/// @brief Data is truncated
class DataTruncated : public Exception {
public:

View File

@@ -117,6 +117,7 @@ libkea_dhcpsrv_la_SOURCES += d2_client_mgr.cc d2_client_mgr.h
libkea_dhcpsrv_la_SOURCES += daemon.cc daemon.h
libkea_dhcpsrv_la_SOURCES += db_type.h
libkea_dhcpsrv_la_SOURCES += dhcp4o6_ipc.cc dhcp4o6_ipc.h
libkea_dhcpsrv_la_SOURCES += dhcpsrv_exceptions.h
libkea_dhcpsrv_la_SOURCES += dhcpsrv_log.cc dhcpsrv_log.h
libkea_dhcpsrv_la_SOURCES += host.cc host.h
libkea_dhcpsrv_la_SOURCES += host_container.h
@@ -270,6 +271,7 @@ libkea_dhcpsrv_include_HEADERS = \
client_class_def.h \
csv_lease_file4.h \
csv_lease_file6.h \
dhcpsrv_exceptions.h \
d2_client_cfg.h \
d2_client_mgr.h \
daemon.h \

View File

@@ -19,6 +19,7 @@
#include <config.h>
#include <dhcpsrv/cql_lease_mgr.h>
#include <dhcpsrv/dhcpsrv_exceptions.h>
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcp/duid.h>

View File

@@ -22,6 +22,7 @@
#include <dhcp/hwaddr.h>
#include <dhcpsrv/cql_connection.h>
#include <dhcpsrv/cql_exchange.h>
#include <dhcpsrv/dhcpsrv_exceptions.h>
#include <dhcpsrv/lease_mgr.h>
#include <boost/scoped_ptr.hpp>
@@ -393,7 +394,7 @@ public:
///
/// @param lease4 The lease to be updated.
///
/// @throw isc::db::NoSuchLease Attempt to update a lease that did not
/// @throw isc::dhcp::NoSuchLease Attempt to update a lease that did not
/// exist.
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
@@ -406,7 +407,7 @@ public:
///
/// @param lease6 The lease to be updated.
///
/// @throw isc::db::NoSuchLease Attempt to update a lease that did not
/// @throw isc::dhcp::NoSuchLease Attempt to update a lease that did not
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef DHCPSRV_EXCEPTIONS_H
#define DHCPSRV_EXCEPTIONS_H
#include <exceptions/exceptions.h>
namespace isc {
namespace dhcp {
/// @brief Attempt to update lease that was not there
class NoSuchLease : public Exception {
public:
NoSuchLease(const char* file, size_t line, const char* what) :
isc::Exception(file, line, what) {}
};
} // end of namespace isc::dhcp
} // end of namespace isc
#endif // DHCPSRV_EXCEPTIONS_H

View File

@@ -7,6 +7,7 @@
#include <config.h>
#include <database/database_connection.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/dhcpsrv_exceptions.h>
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcpsrv/lease_file_loader.h>
#include <dhcpsrv/memfile_lease_mgr.h>

View File

@@ -8,6 +8,7 @@
#define MYSQL_LEASE_MGR_H
#include <dhcp/hwaddr.h>
#include <dhcpsrv/dhcpsrv_exceptions.h>
#include <dhcpsrv/lease_mgr.h>
#include <dhcpsrv/mysql_connection.h>
@@ -377,7 +378,7 @@ public:
///
/// @param lease4 The lease to be updated.
///
/// @throw isc::db::NoSuchLease Attempt to update a lease that did not
/// @throw isc::dhcp::NoSuchLease Attempt to update a lease that did not
/// exist.
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
@@ -390,7 +391,7 @@ public:
///
/// @param lease6 The lease to be updated.
///
/// @throw isc::db::NoSuchLease Attempt to update a lease that did not
/// @throw isc::dhcp::NoSuchLease Attempt to update a lease that did not
/// exist.
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.

View File

@@ -10,6 +10,7 @@
#include <dhcp/duid.h>
#include <dhcp/hwaddr.h>
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcpsrv/dhcpsrv_exceptions.h>
#include <dhcpsrv/pgsql_lease_mgr.h>
#include <boost/static_assert.hpp>

View File

@@ -8,6 +8,7 @@
#define PGSQL_LEASE_MGR_H
#include <dhcp/hwaddr.h>
#include <dhcpsrv/dhcpsrv_exceptions.h>
#include <dhcpsrv/lease_mgr.h>
#include <dhcpsrv/pgsql_connection.h>
#include <dhcpsrv/pgsql_exchange.h>
@@ -349,7 +350,7 @@ public:
///
/// @param lease4 The lease to be updated.
///
/// @throw isc::db::NoSuchLease Attempt to update a lease that did not
/// @throw isc::dhcp::NoSuchLease Attempt to update a lease that did not
/// exist.
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
@@ -362,7 +363,7 @@ public:
///
/// @param lease6 The lease to be updated.
///
/// @throw isc::db::NoSuchLease Attempt to update a lease that did not
/// @throw isc::dhcp::NoSuchLease Attempt to update a lease that did not
/// exist.
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.

View File

@@ -10,6 +10,7 @@
#include <database/database_connection.h>
#include <database/db_exceptions.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/dhcpsrv_exceptions.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/tests/generic_lease_mgr_unittest.h>
#include <dhcpsrv/tests/test_utils.h>
@@ -1757,7 +1758,7 @@ GenericLeaseMgrTest::testUpdateLease4() {
// Try updating a lease not in the database.
lmptr_->deleteLease(ioaddress4_[2]);
EXPECT_THROW(lmptr_->updateLease4(leases[2]), isc::db::NoSuchLease);
EXPECT_THROW(lmptr_->updateLease4(leases[2]), isc::dhcp::NoSuchLease);
}
void
@@ -1816,7 +1817,7 @@ GenericLeaseMgrTest::testUpdateLease6() {
EXPECT_THROW(lmptr_->updateLease6(leases[1]), isc::db::DbOperationError);
// Try updating a lease not in the database.
EXPECT_THROW(lmptr_->updateLease6(leases[2]), isc::db::NoSuchLease);
EXPECT_THROW(lmptr_->updateLease6(leases[2]), isc::dhcp::NoSuchLease);
}
void