User Tools

Site Tools


exception_handler_winforms

This is an old revision of the document!


Exception handler for a WinForms application

The following code can be used to display an exception in a Windows Forms application. Please don't forget to log the exception also somewhere.

class wfExceptionEventHandler
	
constructor( oSender as object, oArgs as ThreadExceptionEventArgs )
local oException as Exception
local nResult as DialogResult
local cMessage as string
	
oException := oArgs:Exception
cMessage := "An error has been occurred:" + e"\n\n" + oException:Message + e"\n\n" + ;
               oException:StackTrace + e"\n\n" + "Continue execution?"
								
nResult := MessageBox.Show( cMessage, "Runtime error", MessageBoxButtons.YesNo )									
if nResult == DialogResult.No
  Application.Exit()
endif
	
return	

end class
exception_handler_winforms.1522001152.txt.gz · Last modified: 2018/03/25 18:05 by wolfgangriedmann