From: Mike Taylor Date: Tue, 8 Oct 2002 23:55:52 +0000 (+0000) Subject: Catch exceptions by reference (not that it actually helps with the X-Git-Tag: YAZPP.0.5~60 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=927890f041728f42cb5e1ed3646fce2f07b4f52c;p=yazpp-moved-to-github.git Catch exceptions by reference (not that it actually helps with the memory management or anything, but it does seem to be idiomatic C++) --- diff --git a/zoom/zclient.cpp b/zoom/zclient.cpp index 863968d..16a2ae3 100644 --- a/zoom/zclient.cpp +++ b/zoom/zclient.cpp @@ -1,11 +1,12 @@ -// $Header: /home/cvsroot/yaz++/zoom/zclient.cpp,v 1.2 2002-08-08 16:06:08 mike Exp $ +// $Header: /home/cvsroot/yaz++/zoom/zclient.cpp,v 1.3 2002-10-08 23:55:52 mike Exp $ -// Trivial sample client +// Simple sample client #include // for atoi() #include #include "zoom++.h" + int main(int argc, char **argv) { if (argc != 5) { @@ -22,11 +23,11 @@ int main(int argc, char **argv) ZOOM::connection *conn; try { conn = new ZOOM::connection(hostname, port); - } catch(ZOOM::bib1Exception err) { + } catch(ZOOM::bib1Exception& err) { cerr << argv[0] << ": connect: bib1Exception " << err.errmsg() << " (" << err.addinfo() << ")\n"; return 2; - } catch(ZOOM::exception err) { + } catch(ZOOM::exception& err) { cerr << argv[0] << ": connect: exception " << err.errmsg() << "\n"; return 2; @@ -38,7 +39,8 @@ int main(int argc, char **argv) try { rs = new ZOOM::resultSet(*conn, pq); } catch(ZOOM::bib1Exception err) { - cerr << argv[0] << ": searchSpec: " << + //fprintf(stderr, "caught exception 0x%lx\n", (long) &err); + cerr << argv[0] << ": search: " << err.errmsg() << " (" << err.addinfo() << ")\n"; return 3; }