BIND 10 trac1253, updated. 2a2aa4ccfb548b2a18b10e97acd80df324c5d4a8 [1253] update docs and add safeguard catch
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Oct 6 11:14:55 UTC 2011
The branch, trac1253 has been updated
via 2a2aa4ccfb548b2a18b10e97acd80df324c5d4a8 (commit)
from 02acd96cff43650110f4af6d2fb2a8143887ac00 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2a2aa4ccfb548b2a18b10e97acd80df324c5d4a8
Author: Jelte Jansen <jelte at isc.org>
Date: Thu Oct 6 13:14:43 2011 +0200
[1253] update docs and add safeguard catch
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/factory.cc | 11 ++++++++---
src/lib/datasrc/factory.h | 5 +++--
src/lib/datasrc/memory_datasrc.cc | 7 ++++++-
src/lib/datasrc/memory_datasrc.h | 6 ++++++
src/lib/datasrc/sqlite3_accessor.cc | 4 ++--
src/lib/datasrc/sqlite3_accessor.h | 6 ++++++
src/lib/python/isc/datasrc/datasrc.cc | 5 -----
7 files changed, 31 insertions(+), 13 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/factory.cc b/src/lib/datasrc/factory.cc
index 9904979..d925b69 100644
--- a/src/lib/datasrc/factory.cc
+++ b/src/lib/datasrc/factory.cc
@@ -71,9 +71,14 @@ DataSourceClientContainer::DataSourceClientContainer(const std::string& type,
destructor_ = (ds_destructor*)ds_lib_.getSym("destroyInstance");
std::string error;
- instance_ = ds_create(config, error);
- if (instance_ == NULL) {
- isc_throw(DataSourceError, error);
+ try {
+ instance_ = ds_create(config, error);
+ if (instance_ == NULL) {
+ isc_throw(DataSourceError, error);
+ }
+ } catch (const std::exception& exc) {
+ isc_throw(DataSourceError, "Unknown uncaugt exception from " + type +
+ " createInstance" + exc.what());
}
}
diff --git a/src/lib/datasrc/factory.h b/src/lib/datasrc/factory.h
index dffdd2d..0284067 100644
--- a/src/lib/datasrc/factory.h
+++ b/src/lib/datasrc/factory.h
@@ -133,8 +133,9 @@ public:
/// backend library
/// \exception DataSourceLibrarySymbolError if the library does not have
/// the needed symbols, or if there is an error reading them
- /// \exception DataSourceConfigError if the given config is not correct
- /// for the given type
+ /// \exception DataError if the given config is not correct
+ /// for the given type, or if there was a problem during
+ /// initialization
///
/// \param type The type of the datasource client. Based on the value of
/// type, a specific backend library is used, by appending the
diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc
index 0b96121..c1b1cb1 100644
--- a/src/lib/datasrc/memory_datasrc.cc
+++ b/src/lib/datasrc/memory_datasrc.cc
@@ -937,7 +937,12 @@ createInstance(isc::data::ConstElementPtr config, std::string& error) {
error = "Configuration error: " + errors->str();
return (NULL);
}
- return (new InMemoryClient());
+ try {
+ return (new InMemoryClient());
+ } catch (const std::exception& exc) {
+ error = std::string("Error creating memory datasource: ") + exc.what();
+ return (NULL);
+ }
}
void destroyInstance(DataSourceClient* instance) {
diff --git a/src/lib/datasrc/memory_datasrc.h b/src/lib/datasrc/memory_datasrc.h
index c95d0b3..610deff 100644
--- a/src/lib/datasrc/memory_datasrc.h
+++ b/src/lib/datasrc/memory_datasrc.h
@@ -310,6 +310,12 @@ private:
///
/// This configuration setup is currently under discussion and will change in
/// the near future.
+///
+/// \param config The configuration for the datasource instance
+/// \param error This string will be set to an error message if an error occurs
+/// during initialization
+/// \return An instance of the memory datasource client, or NULL if there was
+/// an error
extern "C" DataSourceClient* createInstance(isc::data::ConstElementPtr config,
std::string& error);
diff --git a/src/lib/datasrc/sqlite3_accessor.cc b/src/lib/datasrc/sqlite3_accessor.cc
index 177c2cf..b64d186 100644
--- a/src/lib/datasrc/sqlite3_accessor.cc
+++ b/src/lib/datasrc/sqlite3_accessor.cc
@@ -763,7 +763,7 @@ DataSourceClient *
createInstance(isc::data::ConstElementPtr config, std::string& error) {
ElementPtr errors(Element::createList());
if (!checkConfig(config, errors)) {
- error = std::string("Configuration error: " + errors->str());
+ error = "Configuration error: " + errors->str();
return (NULL);
}
std::string dbfile = config->get(CONFIG_ITEM_DATABASE_FILE)->stringValue();
@@ -772,7 +772,7 @@ createInstance(isc::data::ConstElementPtr config, std::string& error) {
new SQLite3Accessor(dbfile, isc::dns::RRClass::IN()));
return (new DatabaseClient(isc::dns::RRClass::IN(), sqlite3_accessor));
} catch (const std::exception& exc) {
- error = exc.what();
+ error = std::string("Error creating sqlite3 datasource: ") + exc.what();
return (NULL);
}
}
diff --git a/src/lib/datasrc/sqlite3_accessor.h b/src/lib/datasrc/sqlite3_accessor.h
index b0c09f3..78ca238 100644
--- a/src/lib/datasrc/sqlite3_accessor.h
+++ b/src/lib/datasrc/sqlite3_accessor.h
@@ -200,6 +200,12 @@ private:
///
/// This configuration setup is currently under discussion and will change in
/// the near future.
+///
+/// \param config The configuration for the datasource instance
+/// \param error This string will be set to an error message if an error occurs
+/// during initialization
+/// \return An instance of the sqlite3 datasource client, or NULL if there was
+/// an error
extern "C" DataSourceClient* createInstance(isc::data::ConstElementPtr config,
std::string& error);
diff --git a/src/lib/python/isc/datasrc/datasrc.cc b/src/lib/python/isc/datasrc/datasrc.cc
index 61f9a87..4b0324a 100644
--- a/src/lib/python/isc/datasrc/datasrc.cc
+++ b/src/lib/python/isc/datasrc/datasrc.cc
@@ -163,7 +163,6 @@ initModulePart_ZoneUpdater(PyObject* mod) {
PyObject* po_DataSourceError;
-PyObject* po_DataSourceConfigError;
PyObject* po_NotImplemented;
PyModuleDef iscDataSrc = {
@@ -213,10 +212,6 @@ PyInit_datasrc(void) {
po_DataSourceError = PyErr_NewException("isc.datasrc.Error", NULL,
NULL);
PyObjectContainer(po_DataSourceError).installToModule(mod, "Error");
- po_DataSourceConfigError = PyErr_NewException("isc.datasrc.ConfigError",
- NULL, NULL);
- PyObjectContainer(po_DataSourceConfigError).installToModule(mod,
- "ConfigError");
po_NotImplemented = PyErr_NewException("isc.datasrc.NotImplemented",
NULL, NULL);
PyObjectContainer(po_NotImplemented).installToModule(mod,
More information about the bind10-changes
mailing list