void GException::AddErrorDetail(const char* szSystem, int error, ...) { int nSubSystem = 0; int nError = error; try { GProfile &ErrorProfile = GetErrorProfile(); nSubSystem = atoi(ErrorProfile.GetString(szSystem, "SubSystem")); GString strKey; strKey.Format("%ld", (int)error); strKey = ErrorProfile.GetString(szSystem, (const char *)strKey); GString strTemp; va_list argList; va_start(argList, error); strTemp.FormatV((const char *)strKey, argList); va_end(argList); GString strAddedToUserStack; strAddedToUserStack.Format("[Error %ld:%ld] %s\n", (int)nSubSystem, (int)nError, (const char *)strTemp); _ErrorDetail.AddLast(strAddedToUserStack); } catch (GException &e) { _subSystem = e._subSystem; _error = e._error; _strExceptionReason = e._strExceptionReason; return; } }
GException::GException(const char* szSystem, int error, ...) { _subSystem = 0; _error = error; try { GProfile &ErrorProfile = GetErrorProfile(); if (ErrorProfile.DoesExist(szSystem, "SubSystem")) { _subSystem = atoi(ErrorProfile.GetStringOrDefault(szSystem, "SubSystem","0")); } else { _subSystem = 0; } if (_subSystem == 0) // string resources not loaded { _subSystem = 0; _error = error; _strExceptionReason = "String resource descriptions not loaded"; return; } GString strKey; strKey.Format("%ld", (int)error); if (ErrorProfile.DoesExist(szSystem, (const char *)strKey)) { strKey = ErrorProfile.GetStringOrDefault(szSystem, (const char *)strKey, "String Resource Not Found"); } else { strKey = "String Resource Not Found"; } va_list argList; va_start(argList, error); _strExceptionReason.FormatV((const char *)strKey, argList); va_end(argList); } catch (GException &e) { _subSystem = e._subSystem; _error = e._error; _strExceptionReason = e._strExceptionReason; return; } #if defined ( _WIN32) && defined (_DEBUG) && !defined(__WINPHONE) // this can only be executed if we are NOT out of memory char *pMemTest = new char[128000]; if (pMemTest) { delete pMemTest; _se_translator_function f; f = _set_se_translator(_stack_se_translator); try { int div = 0; #ifdef _MyOwnSlash // breakin the law. Intentionally dividing by 0 to invoke the exception handler. int crash = 1\div; #else int crash = 1/div; #endif crash++; // so that the local variable is used. } catch (GCallStack *gcs)// Note: if the library is not built with the /EHa flag == (Enable C++ Exceptions - Yes with Structured Exceptions) THEN this catch is ignored { _stk.AppendList( gcs->GetStack() ); _set_se_translator(f); delete gcs; } _set_se_translator(f); } #endif }
GException::GException(const char* szSystem, int error, ...) { _subSystem = 0; _error = error; try { GProfile &ErrorProfile = GetErrorProfile(); if (ErrorProfile.DoesExist(szSystem, "SubSystem")) { _subSystem = atoi(ErrorProfile.GetStringOrDefault(szSystem, "SubSystem","0")); } else { _subSystem = 0; } if (_subSystem == 0) // string resources not loaded { _subSystem = 0; _error = error; Format("%s", "String resource descriptions not loaded"); return; } GString strKey; strKey.Format("%ld", (int)error); if (ErrorProfile.DoesExist(szSystem, (const char *)strKey)) { strKey = ErrorProfile.GetStringOrDefault(szSystem, (const char *)strKey, "String Resource Not Found"); } else { strKey = "String Resource Not Found"; } va_list argList; va_start(argList, error); FormatV((const char *)strKey, argList); va_end(argList); } catch (GException &e) { _subSystem = e._subSystem; _error = e._error; Format("%s", (const char *)e); return; } #if defined GCallStack && _WIN32 // record the callstack. _se_translator_function f; f = _set_se_translator(_stack_se_translator); try { int div = 0; #ifdef _MyOwnSlash // breakin the law. int crash = 1\div; #else int crash = 1/div; #endif } catch (GCallStack &gcs) { _stk = *gcs.GetStack(); } _set_se_translator(f); #endif }