From: Jeremy B. <je...@de...> - 2005-11-20 23:03:27
|
I bet that SetUnhandledExceptionFilter would do the trick for you. See MSDN for how to use it. But one of the return codes from your filter function can be to ignore the exception and keep going. ----- Original Message ----- From: "John Brown" <joh...@ho...> To: <Min...@li...> Sent: Sunday, November 20, 2005 1:52 PM Subject: [Mingw-users] Using Structured Exception handling in Mingw > Hello All, > > I simply want to swallow the exception and have the program move on as if > nothing happened. Is that possible? I can catch the exception, but the > program dies before the function returns. In short, I want to implementa > VB "On Error Resume Next" > > I am trying to fix a problem in MPlayer (an open source media player - > http://www.mplayerhq.hu) that only occurs on particular files. I know > nothing about video or audio encoding, so I cannot fix the code properly. > I am hoping that if I trap the exception and let the problem function > return failure to the calling function, then that will be good enough. > > Please see my test code below: > > /* ******************** Begin Program**************************/ > #include <windows.h> > #include <excpt.h> > #include <stdio.h> > > int rc = FALSE; > > EXCEPTION_DISPOSITION MyHandler > (struct _EXCEPTION_RECORD* er, void* buf, struct _CONTEXT* ctx, void* > buf2) > { > rc = FALSE; > MessageBox(NULL, "Excellent! But how do I execute the statment after the > offending one?\n" > "I want testxcpt() return FALSE to main()", > "Exception Caught", MB_OK); > return ExceptionNestedException; > } > > int testxcpt() > { > char c; > char *s = NULL; > int rc = FALSE; > > __try1(MyHandler){ > > printf("Generate exception? y/n: "); > fflush(stdin); > switch(getchar()){ > case 'y': > case 'Y': > *s = *s; /* de-referencing NULL pointer */ > break; > case 'n': > case 'N': > s = "s"; > rc = TRUE; > break; > default: > printf("I said enter y or n!\n"); > } > return rc; > } > __except1; > return rc; > } > > int main() > { > if (testxcpt()) > printf("testxcpt() succeeded\n"); > else > printf("testxcpt() failed\n"); > return 0; > } > /**************** End Program ********************/ > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. Get Certified Today > Register for a JBoss Training Course. Free Certification Exam > for All Training Attendees Through End of 2005. For more info visit: > http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click > _______________________________________________ > MinGW-users mailing list > Min...@li... > > You may change your MinGW Account Options or unsubscribe at: > https://lists.sourceforge.net/lists/listinfo/mingw-users > |