1 // $Header: /home/cvsroot/yaz++/zoom/zexcept.cpp,v 1.8 2003-07-02 10:25:13 adam Exp $
3 // Z39.50 Exception classes
7 #include <string.h> // for strerror(), strlen(), strcpy()
12 exception::exception(int errcode) {
16 exception::~exception() {
17 // Nothing to do, but G++ requires this to be explicit anyway
20 int exception::errcode() const {
24 std::string exception::errmsg() const {
26 sprintf(buf, "error #%d", code);
32 systemException::systemException() : exception(errno){
36 std::string systemException::errmsg() const {
37 return strerror(code);
42 bib1Exception::bib1Exception(int errcode, const std::string &addinfo) :
43 exception(errcode), info(addinfo) {
44 std::cerr << "WARNING: made bib1Exception(" << errcode << "=" <<
45 ZOOM_diag_str(errcode) << ", '" << addinfo << "')\n";
48 bib1Exception::~bib1Exception() {
49 //fprintf(stderr, "deleting bib1Exception 0x%lx (%d, 0x%lx=%s)\n",
50 //(long) this, code, (long) info, info);
52 // ### Don't actually do the deletion for now. Exception
53 // reference semantics are too weird for me to grok so I'm
54 // doing The Wrong Thing in the knowledge that it will more
55 // or less work -- it just leaks memory. (Or does it?)
58 std::string bib1Exception::errmsg() const {
59 return ZOOM_diag_str(code);
62 std::string bib1Exception::addinfo() const {
68 queryException::queryException(int qtype, const std::string &source) :
69 exception(qtype), q(source) {}
71 queryException::~queryException() {
72 //delete q; // ### see comment on bib1Exception destructor
75 std::string queryException::errmsg() const {
77 case PREFIX: return "bad prefix search";
78 case CCL: return "bad CCL search";
81 return "bad search (unknown type)";
84 std::string queryException::addinfo() const {