mirror of
https://github.com/glest/glest-source.git
synced 2025-08-22 16:02:50 +02:00
- a little cleanup of windows exception handling code
This commit is contained in:
@@ -98,18 +98,21 @@ enum GAME_ARG_TYPE {
|
|||||||
GAME_ARG_VALIDATE_FACTIONS
|
GAME_ARG_VALIDATE_FACTIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
string runtimeErrorMsg = "";
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)
|
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)
|
||||||
void fatal(const char *s, ...) // failure exit
|
void fatal(const char *s, ...) // failure exit
|
||||||
{
|
{
|
||||||
static int errors = 0;
|
static int errors = 0;
|
||||||
errors++;
|
errors++;
|
||||||
|
|
||||||
if(errors <= 3) { // print up to two extra recursive errors
|
if(errors <= 5) { // print up to two extra recursive errors
|
||||||
defvformatstring(msg,s,s);
|
defvformatstring(msg,s,s);
|
||||||
|
string errText = string(msg) + " [" + runtimeErrorMsg + "]";
|
||||||
//puts(msg);
|
//puts(msg);
|
||||||
string sErr = string(GameConstants::application_name) + " fatal error";
|
string sErr = string(GameConstants::application_name) + " fatal error";
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",msg);
|
SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",errText.c_str());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",errText.c_str());
|
||||||
|
|
||||||
if(errors <= 1) { // avoid recursion
|
if(errors <= 1) { // avoid recursion
|
||||||
if(SDL_WasInit(SDL_INIT_VIDEO)) {
|
if(SDL_WasInit(SDL_INIT_VIDEO)) {
|
||||||
@@ -118,7 +121,7 @@ void fatal(const char *s, ...) // failure exit
|
|||||||
SDL_SetGamma(1, 1, 1);
|
SDL_SetGamma(1, 1, 1);
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
MessageBox(NULL, msg, sErr.c_str(), MB_OK|MB_SYSTEMMODAL);
|
MessageBox(NULL, errText.c_str(), sErr.c_str(), MB_OK|MB_SYSTEMMODAL);
|
||||||
#endif
|
#endif
|
||||||
//SDL_Quit();
|
//SDL_Quit();
|
||||||
}
|
}
|
||||||
@@ -161,9 +164,9 @@ class ExceptionHandler: public PlatformExceptionHandler{
|
|||||||
public:
|
public:
|
||||||
virtual void handle() {
|
virtual void handle() {
|
||||||
string msg = "#1 An error ocurred and " + string(GameConstants::application_name) + " will close.\nPlease report this bug to "+mailString;
|
string msg = "#1 An error ocurred and " + string(GameConstants::application_name) + " will close.\nPlease report this bug to "+mailString;
|
||||||
//#ifdef WIN32
|
#ifdef WIN32
|
||||||
// msg += ", attaching the generated " + getCrashDumpFileName()+ " file.";
|
msg += ", attaching the generated " + getCrashDumpFileName()+ " file.";
|
||||||
//#endif
|
#endif
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",msg.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",msg.c_str());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg.c_str());
|
||||||
|
|
||||||
@@ -195,6 +198,15 @@ public:
|
|||||||
}
|
}
|
||||||
showCursor(true);
|
showCursor(true);
|
||||||
restoreVideoMode(true);
|
restoreVideoMode(true);
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
runtimeErrorMsg = "";
|
||||||
|
if(msg != NULL) {
|
||||||
|
runtimeErrorMsg = msg;
|
||||||
|
}
|
||||||
|
throw runtimeErrorMsg;
|
||||||
|
#endif
|
||||||
//SystemFlags::Close();
|
//SystemFlags::Close();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -668,9 +680,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
ExceptionHandler exceptionHandler;
|
ExceptionHandler exceptionHandler;
|
||||||
exceptionHandler.install( getCrashDumpFileName() );
|
exceptionHandler.install( getCrashDumpFileName() );
|
||||||
|
|
||||||
#ifndef WIN32_STACK_TRACE
|
|
||||||
try {
|
try {
|
||||||
#endif
|
|
||||||
std::auto_ptr<FileCRCPreCacheThread> preCacheThread;
|
std::auto_ptr<FileCRCPreCacheThread> preCacheThread;
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str()));
|
FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str()));
|
||||||
@@ -1073,7 +1083,6 @@ int glestMain(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
#ifndef WIN32_STACK_TRACE
|
|
||||||
}
|
}
|
||||||
catch(const exception &e){
|
catch(const exception &e){
|
||||||
ExceptionHandler::handleRuntimeError(e.what());
|
ExceptionHandler::handleRuntimeError(e.what());
|
||||||
@@ -1087,7 +1096,6 @@ int glestMain(int argc, char** argv) {
|
|||||||
catch(...){
|
catch(...){
|
||||||
ExceptionHandler::handleRuntimeError("Unknown error!");
|
ExceptionHandler::handleRuntimeError("Unknown error!");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user