Skip to main content
GameDev.net gamedev.net
🔒 Locked

Catching general errors

Started by SikCiv Sep 4, 2000 at 5:54 PM 3 replies 500+ views
Original Post
SikCiv
SikCiv
My app has a bug *somewhere* and im trying to find out the source of the problem. The app crashes and gives a protection error (or something similar) and displays a small dialog with a close button. I have implemented a debugging output system where my app writes to a text file when it runs certain functions, but since the app crashes without closing, it doesnt close my debug file, so i cannot find the source of the problem. (I am not using the Developer studio, just the command line). Is there a way to catch a protection fault in my app instead of the app causing an error and forcing it to close?
  Downloads:  ZeroOne Realm
SikCiv
SikCiv
The file output is not a problem, ive made it so it saves the file at every debug output.

What I would like to know is is it possible to catch a GPF from my app before windows gets it and displays a message?
  Downloads:  ZeroOne Realm
Stoffel
Stoffel
exceptions are your answer. Here''s a code snipped that will throw an exception for trying to write to a null pointer:
    
#include <iostream>

using namespace std;

int main ()
{
try
{
int *p = NULL;
*p = 5;
}
catch(...)
{
cout << "Exception thrown in try block" << endl;
return 1;
}
return 0;
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.