mirror of
https://github.com/glest/glest-source.git
synced 2025-08-21 15:41:24 +02:00
Added more error condition checks and re-throw runtime_error in SDL event handler so we get a nice messagebox in the game
This commit is contained in:
@@ -58,7 +58,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void handleRuntimeError(const char *msg) {
|
static void handleRuntimeError(const char *msg) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,msg);
|
||||||
|
|
||||||
Program *program = Program::getInstance();
|
Program *program = Program::getInstance();
|
||||||
if(program && gameInitialized == true) {
|
if(program && gameInitialized == true) {
|
||||||
@@ -74,6 +74,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int DisplayMessage(const char *msg, bool exitApp) {
|
static int DisplayMessage(const char *msg, bool exitApp) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,msg);
|
||||||
|
|
||||||
Program *program = Program::getInstance();
|
Program *program = Program::getInstance();
|
||||||
if(program && gameInitialized == true) {
|
if(program && gameInitialized == true) {
|
||||||
@@ -318,6 +319,18 @@ int glestMain(int argc, char** argv){
|
|||||||
//exceptionMessage(e);
|
//exceptionMessage(e);
|
||||||
ExceptionHandler::handleRuntimeError(e.what());
|
ExceptionHandler::handleRuntimeError(e.what());
|
||||||
}
|
}
|
||||||
|
catch(const char *e){
|
||||||
|
//exceptionMessage(e);
|
||||||
|
ExceptionHandler::handleRuntimeError(e);
|
||||||
|
}
|
||||||
|
catch(const string &ex){
|
||||||
|
//exceptionMessage(e);
|
||||||
|
ExceptionHandler::handleRuntimeError(ex.c_str());
|
||||||
|
}
|
||||||
|
catch(...){
|
||||||
|
//exceptionMessage(e);
|
||||||
|
ExceptionHandler::handleRuntimeError("Unknown error!");
|
||||||
|
}
|
||||||
|
|
||||||
//SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
//SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
//soundRenderer.stopAllSounds();
|
//soundRenderer.stopAllSounds();
|
||||||
|
@@ -234,6 +234,9 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy){
|
|||||||
0, glFormat, GL_UNSIGNED_BYTE, pixels);
|
0, glFormat, GL_UNSIGNED_BYTE, pixels);
|
||||||
|
|
||||||
GLint error= glGetError();
|
GLint error= glGetError();
|
||||||
|
|
||||||
|
//throw runtime_error("TEST!");
|
||||||
|
|
||||||
if(error!=GL_NO_ERROR){
|
if(error!=GL_NO_ERROR){
|
||||||
char szBuf[1024]="";
|
char szBuf[1024]="";
|
||||||
sprintf(szBuf,"Error creating texture 2D, returned: %d [%s] w = %d, h = %d, glInternalFormat = %d, glFormat = %d",error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH(),glInternalFormat,glFormat);
|
sprintf(szBuf,"Error creating texture 2D, returned: %d [%s] w = %d, h = %d, glInternalFormat = %d, glFormat = %d",error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH(),glInternalFormat,glFormat);
|
||||||
|
@@ -143,8 +143,15 @@ bool Window::handleEvent() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch(std::exception& e) {
|
}
|
||||||
std::cerr << "Couldn't process event: " << e.what() << "\n";
|
catch(std::runtime_error& e) {
|
||||||
|
std::cerr << "(a) Couldn't process event: " << e.what() << "\n";
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (a) Couldn't process event: [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||||
|
throw runtime_error(e.what());
|
||||||
|
}
|
||||||
|
catch(std::exception& e) {
|
||||||
|
std::cerr << "(b) Couldn't process event: " << e.what() << "\n";
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (b) Couldn't process event: [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -149,6 +149,8 @@ PlatformExceptionHandler *PlatformExceptionHandler::thisPointer= NULL;
|
|||||||
|
|
||||||
LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers){
|
LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers){
|
||||||
|
|
||||||
|
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
HANDLE hFile = CreateFile(
|
HANDLE hFile = CreateFile(
|
||||||
thisPointer->dumpFileName.c_str(),
|
thisPointer->dumpFileName.c_str(),
|
||||||
GENERIC_WRITE,
|
GENERIC_WRITE,
|
||||||
@@ -158,6 +160,8 @@ LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers){
|
|||||||
FILE_ATTRIBUTE_NORMAL,
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
MINIDUMP_EXCEPTION_INFORMATION lExceptionInformation;
|
MINIDUMP_EXCEPTION_INFORMATION lExceptionInformation;
|
||||||
|
|
||||||
lExceptionInformation.ThreadId= GetCurrentThreadId();
|
lExceptionInformation.ThreadId= GetCurrentThreadId();
|
||||||
@@ -173,8 +177,12 @@ LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers){
|
|||||||
NULL,
|
NULL,
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
|
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
thisPointer->handle();
|
thisPointer->handle();
|
||||||
|
|
||||||
|
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
return EXCEPTION_EXECUTE_HANDLER;
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user