diff options
author | Stephen D. Huston <shuston@apache.org> | 2009-10-28 23:47:03 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2009-10-28 23:47:03 +0000 |
commit | e70a7bb7fbed5533690fa0fcea1e157867b2b1fa (patch) | |
tree | 7daf6f6a7aff694d937ca83a2bc690303b9badfb /cpp/src/qpid/store | |
parent | 891493f277f6a2895399a955a56bac8f4ef1379a (diff) | |
download | qpid-python-e70a7bb7fbed5533690fa0fcea1e157867b2b1fa.tar.gz |
Change StorageProvider::Exception to inherit from qpid::Exception instead of std::exception; allows the broker to catch them and do something other than die without a message.
Fixed exception handling around more ADO ops and correctly handle com exceptions without associated ErrorInfo.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@830797 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/store')
-rw-r--r-- | cpp/src/qpid/store/MessageStorePlugin.cpp | 5 | ||||
-rw-r--r-- | cpp/src/qpid/store/StorageProvider.h | 3 | ||||
-rw-r--r-- | cpp/src/qpid/store/ms-sql/Exception.h | 11 | ||||
-rw-r--r-- | cpp/src/qpid/store/ms-sql/MSSqlProvider.cpp | 49 |
4 files changed, 42 insertions, 26 deletions
diff --git a/cpp/src/qpid/store/MessageStorePlugin.cpp b/cpp/src/qpid/store/MessageStorePlugin.cpp index 6b6e1f0cde..6720fd13f3 100644 --- a/cpp/src/qpid/store/MessageStorePlugin.cpp +++ b/cpp/src/qpid/store/MessageStorePlugin.cpp @@ -73,6 +73,7 @@ MessageStorePlugin::earlyInitialize (qpid::Plugin::Target& target) if (providers.empty()) { QPID_LOG(warning, "Message store plugin: No storage providers available."); + provider = providers.end(); return; } if (!options.providerName.empty()) { @@ -86,10 +87,12 @@ MessageStorePlugin::earlyInitialize (qpid::Plugin::Target& target) else { // No specific provider chosen; if there's only one, use it. Else // report the need to pick one. - if (providers.size() > 1) + if (providers.size() > 1) { + provider = providers.end(); throw Exception("Message store plugin: multiple provider plugins " "loaded; must either load only one or select one " "using --storage-provider"); + } provider = providers.begin(); } diff --git a/cpp/src/qpid/store/StorageProvider.h b/cpp/src/qpid/store/StorageProvider.h index 701d280e79..5dc10ecf4a 100644 --- a/cpp/src/qpid/store/StorageProvider.h +++ b/cpp/src/qpid/store/StorageProvider.h @@ -25,6 +25,7 @@ #include <map> #include <stdexcept> #include <vector> +#include "qpid/Exception.h" #include "qpid/Plugin.h" #include "qpid/Options.h" #include "qpid/broker/MessageStore.h" @@ -63,7 +64,7 @@ class StorageProvider : public qpid::Plugin, public qpid::broker::MessageStore { public: - class Exception : public std::exception + class Exception : public qpid::Exception { public: virtual ~Exception() throw() {} diff --git a/cpp/src/qpid/store/ms-sql/Exception.h b/cpp/src/qpid/store/ms-sql/Exception.h index 34e401b068..84b7f62739 100644 --- a/cpp/src/qpid/store/ms-sql/Exception.h +++ b/cpp/src/qpid/store/ms-sql/Exception.h @@ -46,8 +46,15 @@ public: ADOException(const std::string& _text, _com_error &e) : Exception(_text) { text += ": "; - _bstr_t wmsg = e.Description(); - text += (const char *)wmsg; + IErrorInfo *i = e.ErrorInfo(); + if (i != 0) { + _bstr_t wmsg = e.Description(); + text += (const char *)wmsg; + i->Release(); + } + else { + text += e.ErrorMessage(); + } } }; diff --git a/cpp/src/qpid/store/ms-sql/MSSqlProvider.cpp b/cpp/src/qpid/store/ms-sql/MSSqlProvider.cpp index cb92e2fd80..b8c020fabe 100644 --- a/cpp/src/qpid/store/ms-sql/MSSqlProvider.cpp +++ b/cpp/src/qpid/store/ms-sql/MSSqlProvider.cpp @@ -954,28 +954,33 @@ MSSqlProvider::createDb(_ConnectionPtr conn, const std::string &name) " (messageId bigint REFERENCES tblMessage(persistenceId) NOT NULL," " queueId bigint REFERENCES tblQueue(persistenceId) NOT NULL)"; _variant_t unused; - _bstr_t dbStr = dbCmd.c_str(); - conn->Execute(dbStr, &unused, adExecuteNoRecords); - _bstr_t useStr = useCmd.c_str(); - conn->Execute(useStr, &unused, adExecuteNoRecords); - std::string makeTable = tableCmd + TblQueue + colSpecs; - _bstr_t makeTableStr = makeTable.c_str(); - conn->Execute(makeTableStr, &unused, adExecuteNoRecords); - makeTable = tableCmd + TblExchange + colSpecs; - makeTableStr = makeTable.c_str(); - conn->Execute(makeTableStr, &unused, adExecuteNoRecords); - makeTable = tableCmd + TblConfig + colSpecs; - makeTableStr = makeTable.c_str(); - conn->Execute(makeTableStr, &unused, adExecuteNoRecords); - makeTable = tableCmd + TblMessage + colSpecs; - makeTableStr = makeTable.c_str(); - conn->Execute(makeTableStr, &unused, adExecuteNoRecords); - makeTable = tableCmd + TblBinding + bindingSpecs; - makeTableStr = makeTable.c_str(); - conn->Execute(makeTableStr, &unused, adExecuteNoRecords); - makeTable = tableCmd + TblMessageMap + messageMapSpecs; - makeTableStr = makeTable.c_str(); - conn->Execute(makeTableStr, &unused, adExecuteNoRecords); + _bstr_t dbStr = dbCmd.c_str(); + try { + conn->Execute(dbStr, &unused, adExecuteNoRecords); + _bstr_t useStr = useCmd.c_str(); + conn->Execute(useStr, &unused, adExecuteNoRecords); + std::string makeTable = tableCmd + TblQueue + colSpecs; + _bstr_t makeTableStr = makeTable.c_str(); + conn->Execute(makeTableStr, &unused, adExecuteNoRecords); + makeTable = tableCmd + TblExchange + colSpecs; + makeTableStr = makeTable.c_str(); + conn->Execute(makeTableStr, &unused, adExecuteNoRecords); + makeTable = tableCmd + TblConfig + colSpecs; + makeTableStr = makeTable.c_str(); + conn->Execute(makeTableStr, &unused, adExecuteNoRecords); + makeTable = tableCmd + TblMessage + colSpecs; + makeTableStr = makeTable.c_str(); + conn->Execute(makeTableStr, &unused, adExecuteNoRecords); + makeTable = tableCmd + TblBinding + bindingSpecs; + makeTableStr = makeTable.c_str(); + conn->Execute(makeTableStr, &unused, adExecuteNoRecords); + makeTable = tableCmd + TblMessageMap + messageMapSpecs; + makeTableStr = makeTable.c_str(); + conn->Execute(makeTableStr, &unused, adExecuteNoRecords); + } + catch(_com_error &e) { + throw ADOException("MSSQL can't create " + name, e); + } } void |