exceptions.h

Go to the documentation of this file.
00001 /*
00002  * opencog/util/exceptions.h
00003  *
00004  * Copyright (C) 2002-2007 Novamente LLC
00005  * All Rights Reserved
00006  *
00007  * Written by Thiago Maia <thiago@vettatech.com>
00008  *            Andre Senna <senna@vettalabs.com>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU Affero General Public License v3 as
00012  * published by the Free Software Foundation and including the exceptions
00013  * at http://opencog.org/wiki/Licenses
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Affero General Public License
00021  * along with this program; if not, write to:
00022  * Free Software Foundation, Inc.,
00023  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00024  */
00025 
00026 #ifndef _OPENCOG_EXCEPTIONS_H
00027 #define _OPENCOG_EXCEPTIONS_H
00028 
00029 #include <string>
00030 
00031 #include <stdarg.h>
00032 #include <string.h>
00033 
00034 #define STRINGIFY(x) #x
00035 #define TOSTRING(x) STRINGIFY(x)
00036 #define TRACE_INFO " ("__FILE__":"TOSTRING(__LINE__)")"
00037 
00038 namespace opencog 
00039 {
00040 
00044 class StandardException
00045 {
00046 
00047 private:
00051     char * message;
00052 
00053 protected:
00054 
00059     void parseErrorMessage(const char* fmt, va_list ap, bool logError=true);
00060     void parseErrorMessage(const char * trace, const char* fmt, va_list ap, bool logError=true);
00061 
00062 public:
00063 
00067     StandardException();
00068     ~StandardException();
00069 
00075     const char* getMessage() const;
00076 
00082     void setMessage(const char *);
00083 
00084 }; // StandardException
00085 
00090 class RuntimeException : public StandardException
00091 {
00092 
00093 public:
00094 
00101     RuntimeException(const char*, const char*, ...);
00102 
00106     RuntimeException();
00107 
00111     ~RuntimeException();
00112 
00113 }; // RuntimException
00114 
00118 class XMLException : public RuntimeException
00119 {
00120 
00121 public:
00122 
00130     XMLException(const char*, const char*, ...);
00131 
00132 }; // XMLException
00133 
00137 class IOException : public RuntimeException
00138 {
00139 
00140 public:
00141 
00149     IOException(const char*, const char*, ...);
00150 
00151 }; // IOException
00152 
00156 class ComboException : public RuntimeException
00157 {
00158 
00159 public:
00160 
00168     ComboException(const char*, const char*, ...);
00169 
00170 }; // ComboException
00171 
00175 class IndexErrorException : public RuntimeException
00176 {
00177 
00178 public:
00179 
00187     IndexErrorException(const char*, const char*, ...);
00188 
00189 }; // IndexErrorException
00190 
00198 class InvalidParamException : public RuntimeException
00199 {
00200 
00201 public:
00202 
00210     InvalidParamException(const char*, const char*, ...);
00211 
00212 }; // InvalidParamException
00213 
00218 class InconsistenceException : public RuntimeException
00219 {
00220 
00221 public:
00222 
00230     InconsistenceException(const char*, const char*, ...);
00231 
00232 }; // InconsistenceException
00233 
00238 class FatalErrorException : public StandardException
00239 {
00240 
00241 public:
00242 
00250     FatalErrorException(const char*, const char*, ...);
00251 
00252 }; // FatalErrorException
00253 
00260 class NotFoundException : public StandardException {
00261 public:
00262 
00270     NotFoundException(const char*, const char*, ...);
00271     
00272 }; // NotFoundException
00273 
00278 class NetworkException : public StandardException
00279 {
00280 
00281 public:
00282 
00290     NetworkException(const char*, const char*, ...);
00291 
00292 }; // NetworkException
00293 
00294 
00298 class AssertionException
00299 {
00300 
00301 public:
00302 
00303     AssertionException(const char*, ...);
00304     AssertionException(const char* fmt, va_list ap);
00305 };
00306 
00307 } // namespace opencog
00308 
00309 #endif // _OPENCOG_EXCEPTIONS_H

Generated on Fri Dec 4 23:23:31 2009 for OpenCog Framework by  doxygen 1.5.6