1 // $Header: /home/cvsroot/yaz++/zoom/zexcept.cpp,v 1.1 2002-08-08 16:06:08 mike Exp $
3 // Z39.50 Exception classes
6 #include <string.h> // for strerror(), strlen(), strcpy()
7 #include <stdio.h> // for sprintf()
8 #include <yaz/diagbib1.h>
13 exception::exception(int errcode) {
17 int exception::errcode() const {
21 const char *exception::errmsg() const {
23 sprintf(buf, "error #%d", code);
29 systemException::systemException() : exception::exception(errno){
33 int systemException::errcode() const {
37 const char *systemException::errmsg() const {
38 return strerror(code);
43 bib1Exception::bib1Exception(int errcode, const char *addinfo) :
44 exception::exception(errcode) {
45 info = new char[strlen(addinfo)+1];
46 strcpy((char*) info, addinfo);
49 bib1Exception::~bib1Exception() {
53 int bib1Exception::errcode() const {
57 const char *bib1Exception::errmsg() const {
58 return diagbib1_str(code);
61 const char *bib1Exception::addinfo() const {
67 queryException::queryException(int qtype, const char *source) :
68 exception::exception(qtype) {
69 q = new char[strlen(source)+1];
70 strcpy((char*) q, source);
73 queryException::~queryException() {
77 int queryException::errcode() const {
81 const char *queryException::errmsg() const {
83 case PREFIX: return "bad prefix search";
84 case CCL: return "bad CCL search";
87 return "bad search (unknown type)";
90 const char *queryException::addinfo() const {