1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
|
/* $Id: xbexcept.cpp,v 1.7 2000/11/30 22:15:24 dbryson Exp $
Xbase project source code
This file contains exceptions for error reporting
Copyright (C) 1998 Denis Pershin (dyp@inetlab.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact:
Mail:
Technology Associates, Inc.
XBase Project
1455 Deming Way #11
Sparks, NV 89434
USA
Email:
xbase@techass.com
See our website at:
xdb.sourceforge.net
*/
#ifdef __GNUG__
#pragma implementation "xbexcept.h"
#endif
#ifdef __WIN32__
#include <xbase/xbconfigw32.h>
#else
#include <xbase/xbconfig.h>
#endif
#include <stdlib.h>
#include <xbase/xbase.h>
#include <xbase/retcodes.h>
#include <xbase/xbexcept.h>
#include <xbase/xtypes.h>
/*! \file xbexcept.cpp
*/
//! Short description.
/*!
\param err
*/
const char *xbStrError(xbShort err)
{
switch (err) {
case XB_NO_ERROR:
return "No error";
case XB_EOF:
return "Xbase EoF";
case XB_BOF:
return "XBase BoF";
case XB_NO_MEMORY:
return "Out of memory";
case XB_FILE_EXISTS:
return "File already exists";
case XB_OPEN_ERROR:
return "Error opening file";
case XB_WRITE_ERROR:
return "Error write to file";
case XB_UNKNOWN_FIELD_TYPE:
return "Unknown field type";
case XB_ALREADY_OPEN:
return "File already opened";
case XB_NOT_XBASE:
return "File is not XBase";
case XB_INVALID_RECORD:
return "Invalid record";
case XB_INVALID_OPTION:
return "Invalid option";
case XB_NOT_OPEN:
return "File not opened";
case XB_SEEK_ERROR:
return "Seek error";
case XB_READ_ERROR:
return "Read error";
case XB_NOT_FOUND:
return "Not found";
case XB_FOUND:
return "Found";
case XB_INVALID_KEY:
return "Invalid key";
case XB_INVALID_NODELINK:
return "Invalid nodelink";
case XB_KEY_NOT_UNIQUE:
return "Key not unique";
case XB_INVALID_KEY_EXPRESSION:
return "Invalid key expression";
case XB_DBF_FILE_NOT_OPEN:
return "DBF file not open";
case XB_INVALID_KEY_TYPE:
return "Invalid key type";
case XB_INVALID_NODE_NO:
return "Invalid node no";
case XB_NODE_FULL:
return "Node full";
case XB_INVALID_FIELDNO:
return "Invalid field no";
case XB_INVALID_DATA:
return "Invalid data";
case XB_NOT_LEAFNODE:
return "Not leafnode";
case XB_LOCK_FAILED:
return "Lock failed";
case XB_CLOSE_ERROR:
return "Close error";
case XB_INVALID_SCHEMA:
return "Invalid schema";
case XB_INVALID_NAME:
return "Invlaid name";
case XB_INVALID_BLOCK_SIZE:
return "Invalid block size";
case XB_INVALID_BLOCK_NO:
return "Invalid block no";
case XB_NOT_MEMO_FIELD:
return "Not memo field";
case XB_NO_MEMO_DATA:
return "No memo data";
case XB_EXP_SYNTAX_ERROR:
return "Expression syntax error";
case XB_PARSE_ERROR:
return "Parse error";
case XB_NO_DATA:
return "No data";
case XB_UNKNOWN_TOKEN_TYPE:
return "Unknown token type";
case XB_INVALID_FIELD:
return "Invalid field";
case XB_INSUFFICIENT_PARMS:
return "Insufficient parameters";
case XB_INVALID_FUNCTION:
return "Invalid function";
case XB_INVALID_FIELD_LEN:
return "Invalid field len";
default:
return "Unknown exception";
}
}
#ifdef HAVE_EXCEPTIONS
#include <string.h>
#include <errno.h>
//! Short description.
/*!
\param err
*/
xbException::xbException (int err) {
this->err = err;
}
//! Short description.
/*!
*/
xbException::~xbException () XB_THROW {
}
//! Short description.
/*!
*/
const char* xbException::what() const XB_THROW {
return "xbException";
};
//! Short description.
/*!
*/
int xbException::getErr() {
return err;
};
//! Short description.
/*!
*/
const char *xbException::error() {
return xbStrError(err);
}
//! Short description.
/*!
\param err
*/
xbIOException::xbIOException (int err) : xbException(err) {
m_errno = errno;
name = NULL;
}
//! Short description.
/*!
\param err
\param n
*/
xbIOException::xbIOException (int err, const char *n) : xbException(err) {
name = n;
m_errno = errno;
}
//! Short description.
/*!
*/
xbIOException::~xbIOException () XB_THROW {
}
//! Short description.
/*!
*/
const char* xbIOException::what() const XB_THROW {
return "xbIOException";
};
//! Short description.
/*!
*/
const char *xbIOException::_errno() const {
return (strerror(m_errno));
}
//! Short description.
/*!
*/
xbOpenException::xbOpenException () : xbIOException(XB_OPEN_ERROR) {
}
//! Short description.
/*!
\param n
*/
xbOpenException::xbOpenException (const char *n) : xbIOException(XB_OPEN_ERROR, n) {
}
//! Short description.
/*!
*/
xbOpenException::~xbOpenException () XB_THROW {
}
//! Short description.
/*!
*/
const char* xbOpenException::what() const XB_THROW {
return "xbOpenException";
};
//! Short description.
/*!
*/
xbEoFException::xbEoFException () : xbIOException(XB_EOF) {
}
//! Short description.
/*!
*/
xbEoFException::~xbEoFException () XB_THROW {
}
//! Short description.
/*!
*/
const char* xbEoFException::what() const XB_THROW {
return "xbEoFException";
};
//! Short description.
/*!
*/
xbOutOfMemoryException::xbOutOfMemoryException () : xbException(XB_NO_MEMORY) {
}
//! Short description.
/*!
*/
xbOutOfMemoryException::~xbOutOfMemoryException () XB_THROW {
}
//! Short description.
/*!
*/
const char* xbOutOfMemoryException::what() const XB_THROW {
return "xbOutOfMemoryException";
};
#endif
|