Catching general errors
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
September 04, 2000 06:56 PM
i assume you are using the fstream functions. so all you have to do is flush the output which will write everything in the output buffer to disk. flush it everytime you print something.
September 05, 2000 02:40 AM
If you are using the FILE* functions, do this each time after you write to your debug file...
fflush(fp);
fflush(fp);
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?
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
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;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement