From: Francis Dupont Date: Thu, 28 Feb 2019 14:44:55 +0000 (+0100) Subject: [478-improve-error-message-database-backend-mysql] Better message for not built lease... X-Git-Tag: 465-add-subnet4-update-and-subnet6-update-commands-to-subnet-cmds-hook_base2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f6b59fb62be04aeee7d27d3bcdc897c9742d18a;p=thirdparty%2Fkea.git [478-improve-error-message-database-backend-mysql] Better message for not built lease database type --- diff --git a/src/lib/dhcpsrv/lease_mgr_factory.cc b/src/lib/dhcpsrv/lease_mgr_factory.cc index 73b2734a98..068cfb0e5a 100644 --- a/src/lib/dhcpsrv/lease_mgr_factory.cc +++ b/src/lib/dhcpsrv/lease_mgr_factory.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2019 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 @@ -58,27 +58,40 @@ LeaseMgrFactory::create(const std::string& dbaccess) { // Yes, check what it is. -#ifdef HAVE_MYSQL if (parameters[type] == string("mysql")) { +#ifdef HAVE_MYSQL LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_DB).arg(redacted); getLeaseMgrPtr().reset(new MySqlLeaseMgr(parameters)); return; - } +#else + LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg("mysql"); + isc_throw(InvalidType, "The Kea server has not been built with " + "support for database type: mysql"); #endif -#ifdef HAVE_PGSQL + } + if (parameters[type] == string("postgresql")) { +#ifdef HAVE_PGSQL LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_DB).arg(redacted); getLeaseMgrPtr().reset(new PgSqlLeaseMgr(parameters)); return; - } +#else + LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg("postgresql"); + isc_throw(InvalidType, "The Kea server has not been built with " + "support for database type: postgresql"); #endif -#ifdef HAVE_CQL + } if (parameters[type] == string("cql")) { +#ifdef HAVE_CQL LOG_INFO(dhcpsrv_logger, DHCPSRV_CQL_DB).arg(redacted); getLeaseMgrPtr().reset(new CqlLeaseMgr(parameters)); return; - } +#else + LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg("cql"); + isc_throw(InvalidType, "The Kea server has not been built with " + "support for database type: cql"); #endif + } if (parameters[type] == string("memfile")) { LOG_INFO(dhcpsrv_logger, DHCPSRV_MEMFILE_DB).arg(redacted); getLeaseMgrPtr().reset(new Memfile_LeaseMgr(parameters)); @@ -88,7 +101,7 @@ LeaseMgrFactory::create(const std::string& dbaccess) { // Get here on no match LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg(parameters[type]); isc_throw(InvalidType, "Database access parameter 'type' does " - "not specify a supported database backend:" << parameters[type]); + "not specify a supported database backend: " << parameters[type]); } void