00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ARIDE_EXCEPTION_H
00021 #define ARIDE_EXCEPTION_H
00022
00023 #include <stdio.h>
00024 #include <stdexcept>
00025
00026
00027
00028 enum ExceptionType
00029 {
00030 ARDEV_FATAL_EXCEPTION,
00031 ARDEV_NO_FILE_SPECIFIED,
00032 ARDEV_FILE_NOT_FOUND,
00033 ARDEV_XML_PARSE_FAILED,
00034 ARDEV_ALLOC_ERROR,
00035 ARDEV_FILE_OPEN_FAILED,
00036 ARDEV_BAD_PARAMETER,
00037 ARDEV_NO_HANDLER,
00038 ARDEV_CLASS_NOT_FOUND,
00039 ARDEV_BAD_GUID,
00040
00041 ARDEV_UNKNOWN_EXCEPTION
00042 };
00043
00044 extern const char * ExceptionString[];
00045
00046 class aride_exception : public std::runtime_error
00047 {
00048 public:
00049 aride_exception(ExceptionType _Type,const char* _Function="",int _Line=0,void * _Extra=NULL)
00050 : std::runtime_error(ExceptionString[Type])
00051 {
00052 Type=_Type;
00053 Function=_Function;
00054 Line=_Line;
00055 Extra=_Extra;
00056 };
00057
00058 ExceptionType Type;
00059 const char * Function;
00060 int Line;
00061
00062 void * Extra;
00063
00064 const void Print() const
00065 {
00066 if (Type >= ARDEV_FATAL_EXCEPTION && Type < ARDEV_UNKNOWN_EXCEPTION)
00067 fprintf(stderr,"Exception %d in %s:%d. %s\n",Type,Function,Line,ExceptionString[Type]);
00068 else
00069 fprintf(stderr,"Exception %d in %s:%d. Unknown Exception\n",Type,Function,Line);
00070 };
00071 };
00072
00073 #endif