00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00035 #include "exception.h"
00036
00037 Exception::Exception(EXCEPTION_TYPE _type, const char *_error_msg,
00038 ERROR_ID _error_id,
00039 EXCEPTION_LEVEL _exception_level):type(_type),
00040 error_msg(strdup(_error_msg)),
00041 error_id(_error_id),
00042 exception_level(_exception_level) {
00043 }
00044
00045 Exception::~Exception() {
00046 free((char *) error_msg);
00047 }
00048
00049 void Exception::terminate(int exit_code) {
00050 exit(exit_code);
00051 }
00052
00053 const char *Exception::getDebugMsg() {
00054 std::ostringstream o;
00055 o << endl << endl;
00056 o << "!=============================================!" << endl;
00057 o << "!=================TERMINATION=================!" << endl;
00058 o << "Process Aborted Due To ";
00059 switch (type) {
00060 case exct_argument:
00061 o << "\"InvalidArgumentException\"";
00062 break;
00063 case exct_iostream:
00064 o << "\"IOStreamException\"";
00065 break;
00066 case exct_parse:
00067 o << "\"ParseException\"";
00068 break;
00069 case exct_runtime:
00070 o << "\"RuntimeException\"";
00071 break;
00072 case exct_cast:
00073 o << "\"InvalidCastException\"";
00074 break;
00075 case exct_impl:
00076 o << "\"NotImplementedException\"";
00077 break;
00078 }
00079 switch (exception_level) {
00080 case excl_warning:
00081 o << " [WARNING]";
00082 break;
00083 case excl_error:
00084 o << " [ERROR]";
00085 break;
00086 case excl_fatal:
00087 o << " [FATAL]";
00088 break;
00089 }
00090 o << endl;
00091 o << "Error Code ";
00092 switch (error_id) {
00093 case eid_notset:
00094 o << eid_notset << ": Not Specified";
00095 break;
00096 case eid_argument:
00097 o << eid_argument << ": Invalid Argument";
00098 break;
00099 case eid_stream:
00100 o << eid_stream << ": I/O Stream";
00101 break;
00102 case eid_stream_input:
00103 o << eid_stream_input << ": Input Stream";
00104 break;
00105 case eid_stream_output:
00106 o << eid_stream_output << ": Output Stream";
00107 break;
00108 case eid_parse:
00109 o << eid_parse << ": Parsing";
00110 break;
00111 case eid_parse_query:
00112 o << eid_parse_query << ": Query Parsing";
00113 break;
00114 case eid_parse_xml:
00115 o << eid_parse_xml << ": XML Parsing";
00116 break;
00117 case eid_runtime:
00118 o << eid_runtime << ": Runtime";
00119 break;
00120 case eid_runtime_illegalmode:
00121 o << eid_runtime_illegalmode << ": Illegal Evaluation Mode";
00122 break;
00123 case eid_runtime_bit:
00124 o << eid_runtime_bit << ": BufferIterator Error";
00125 break;
00126 case eid_runtime_tokenconfig:
00127 o << eid_runtime_tokenconfig << ": TokenConfiguration Error";
00128 break;
00129 case eid_runtime_ptlabel:
00130 o << eid_runtime_ptlabel << ": ProjectionTreeLabel Error";
00131 break;
00132 case eid_cast:
00133 o << eid_cast << ": Cast";
00134 break;
00135 case eid_cast_stringnumeric:
00136 o << eid_cast_numericstring << ": String To Numeric Cast";
00137 break;
00138 case eid_cast_numericstring:
00139 o << eid_cast_stringnumeric << ": Numeric To String Cast";
00140 break;
00141 case eid_cast_summation:
00142 o << eid_cast_summation << ": Summation Calculation";
00143 break;
00144 case eid_cast_power:
00145 o << eid_cast_power << ": Power Calculation";
00146 break;
00147 case eid_cast_radical:
00148 o << eid_cast_radical << ": Radical Calculation";
00149 break;
00150 case eid_cast_division:
00151 o << eid_cast_division << ": Division Calculation";
00152 break;
00153 case eid_impl:
00154 o << eid_impl << ": Not Implemented";
00155 break;
00156 }
00157 o << endl;
00158 if (error_msg) {
00159 o << "Debug Message:" << endl << error_msg;
00160 }
00161 o << endl;
00162 o << "!=============================================!" << endl;
00163 o << "!=============================================!" << endl;
00164
00165 return o.str().c_str();
00166 }