diff options
author | Alan Conway <aconway@apache.org> | 2010-06-02 21:21:38 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2010-06-02 21:21:38 +0000 |
commit | 7ae9c3439b5165aedf85fec2f3037fc623eddc9d (patch) | |
tree | 217affd8202df8d2101d018020150fccf8eafdbf | |
parent | 82370f874e14cf7ee9d781a1902572e6bac00926 (diff) | |
download | qpid-python-7ae9c3439b5165aedf85fec2f3037fc623eddc9d.tar.gz |
Fix error string for invalid options, fix exception handling in qpid_send/qpid_receive.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@950763 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | cpp/src/qpid/messaging/Connection.cpp | 2 | ||||
-rw-r--r-- | cpp/src/tests/qpid_receive.cpp | 19 | ||||
-rw-r--r-- | cpp/src/tests/qpid_send.cpp | 15 |
3 files changed, 19 insertions, 17 deletions
diff --git a/cpp/src/qpid/messaging/Connection.cpp b/cpp/src/qpid/messaging/Connection.cpp index 53d37562e7..2bd5ba96f9 100644 --- a/cpp/src/qpid/messaging/Connection.cpp +++ b/cpp/src/qpid/messaging/Connection.cpp @@ -46,7 +46,7 @@ Connection::Connection(const std::string& url, const std::string& o) if (o.empty() || parser.parseMap(options)) { PI::ctor(*this, new qpid::client::amqp0_10::ConnectionImpl(url, options)); } else { - throw InvalidOptionString(o); + throw InvalidOptionString("Invalid option string: " + o); } } Connection::Connection(const std::string& url, const Variant::Map& options) diff --git a/cpp/src/tests/qpid_receive.cpp b/cpp/src/tests/qpid_receive.cpp index 15b8d763eb..294a60b8cc 100644 --- a/cpp/src/tests/qpid_receive.cpp +++ b/cpp/src/tests/qpid_receive.cpp @@ -103,7 +103,7 @@ struct Options : public qpid::Options ("report-total", qpid::optValue(reportTotal), "Report total throughput and latency statistics") ("report-every", qpid::optValue(reportEvery,"N"), "Report throughput and latency statistics every N messages.") ("report-header", qpid::optValue(reportHeader, "yes|no"), "Headers on report.") ("ready-address", qpid::optValue(readyAddress, "ADDRESS"), - "send a message to this address when ready to receive") + "send a message to this address when ready to receive") ("help", qpid::optValue(help), "print this usage statement"); add(log); } @@ -162,10 +162,11 @@ using namespace qpid::tests; int main(int argc, char ** argv) { - Options opts; - if (opts.parse(argc, argv)) { - Connection connection(opts.url, opts.connectionOptions); - try { + Connection connection; + try { + Options opts; + if (opts.parse(argc, argv)) { + connection = Connection(opts.url, opts.connectionOptions); connection.open(); std::auto_ptr<FailoverUpdates> updates(opts.failoverUpdates ? new FailoverUpdates(connection) : 0); Session session = opts.tx ? connection.createTransactionalSession() : connection.createSession(); @@ -227,10 +228,10 @@ int main(int argc, char ** argv) session.close(); connection.close(); return 0; - } catch(const std::exception& error) { - std::cerr << "Failure: " << error.what() << std::endl; - connection.close(); } + } catch(const std::exception& error) { + std::cerr << "Failure: " << error.what() << std::endl; + connection.close(); + return 1; } - return 1; } diff --git a/cpp/src/tests/qpid_send.cpp b/cpp/src/tests/qpid_send.cpp index 7fef57a966..98d7cd60aa 100644 --- a/cpp/src/tests/qpid_send.cpp +++ b/cpp/src/tests/qpid_send.cpp @@ -247,10 +247,11 @@ class MapContentGenerator : public ContentGenerator { int main(int argc, char ** argv) { + Connection connection; Options opts; - if (opts.parse(argc, argv)) { - Connection connection(opts.url, opts.connectionOptions); - try { + try { + if (opts.parse(argc, argv)) { + connection = Connection(opts.url, opts.connectionOptions); connection.open(); std::auto_ptr<FailoverUpdates> updates(opts.failoverUpdates ? new FailoverUpdates(connection) : 0); Session session = opts.tx ? connection.createTransactionalSession() : connection.createSession(); @@ -327,10 +328,10 @@ int main(int argc, char ** argv) session.close(); connection.close(); return 0; - } catch(const std::exception& error) { - std::cout << "Failed: " << error.what() << std::endl; - connection.close(); } + } catch(const std::exception& error) { + std::cout << "Failed: " << error.what() << std::endl; + connection.close(); + return 1; } - return 1; } |