-// $Header: /home/cvsroot/yaz++/zoom/zexcept.cpp,v 1.1 2002-08-08 16:06:08 mike Exp $
+// $Header: /home/cvsroot/yaz++/zoom/zexcept.cpp,v 1.6 2002-11-12 22:43:56 mike Exp $
// Z39.50 Exception classes
#include <string.h> // for strerror(), strlen(), strcpy()
#include <stdio.h> // for sprintf()
#include <yaz/diagbib1.h>
-#include "zoom++.h"
+#include "zoom.h"
namespace ZOOM {
- systemException::systemException() : exception::exception(errno){
+ systemException::systemException() : exception(errno){
code = errno;
}
- int systemException::errcode() const {
- return code;
- }
-
const char *systemException::errmsg() const {
return strerror(code);
}
-
+
bib1Exception::bib1Exception(int errcode, const char *addinfo) :
- exception::exception(errcode) {
+ exception(errcode) {
info = new char[strlen(addinfo)+1];
strcpy((char*) info, addinfo);
+ //fprintf(stderr, "made new bib1Exception 0x%lx (%d, 0x%lx=%s)\n",
+ //(long) this, code, (long) info, info);
}
- bib1Exception::~bib1Exception() {
- delete info;
+#if 0
+ bib1Exception::bib1Exception(bib1Exception& src) :
+ exception(src) {
+ code = src.code;
+ info = new char[strlen(src.info)+1];
+ strcpy((char*) info, src.info);
+ //fprintf(stderr, "copied bib1Exception 0x%lx to 0x%lx (%d, 0x%lx=%s)\n",
+ //(long) &src, (long) this, code, (long) info, info);
}
+#endif
- int bib1Exception::errcode() const {
- return code;
+ bib1Exception::~bib1Exception() {
+ //fprintf(stderr, "deleting bib1Exception 0x%lx (%d, 0x%lx=%s)\n",
+ //(long) this, code, (long) info, info);
+ //delete info;
+ // ### Don't actually do the deletion for now. Exception
+ // reference semantics are too weird for me to grok so I'm
+ // doing The Wrong Thing in the knowledge that it will more
+ // or less work -- it just leaks memory.
}
const char *bib1Exception::errmsg() const {
queryException::queryException(int qtype, const char *source) :
- exception::exception(qtype) {
+ exception(qtype) {
q = new char[strlen(source)+1];
strcpy((char*) q, source);
}
queryException::~queryException() {
- delete q;
- }
-
- int queryException::errcode() const {
- return code;
+ //delete q; // ### see comment on bib1Exception destructor
}
const char *queryException::errmsg() const {