Catch?

BlitzMax Forums/BlitzMax Beginners Area/Catch?

Try this code from my framework (you may need to modify it):

Function HandleGeneralError(o:Object)
	'This should be called inside the Catch section of a Try/Catch/End Try like this:
	'Try
	'  'some code
	'Catch o:Object
	'  HandleGeneralError(o)
	'  Shutdown()
	'End Try
	
	EndGraphics 'safety to ensure desktop isn't messed up
	ShowMouse() 'make sure user can click on dialog.
	
	'In debug mode, this will display a valid error message.
	'In non-debug mode (final release), this will show a dialog saying "memory execption error"
	'which is better than nothing.
	'In full-screen mode, this will still show a dialog on the desktop after the graphics mode
	'is ended, and when the dialog is clicked, the game will shutdown.
	If TBlitzException(o) Then
		Local Prefix$ = ""
		If DebugInt<> 0 Then Prefix = "("+DebugInt+") "
		Notify Prefix + TBlitzException(o).ToString()
	Else
		'Perhaps a string has been raised? If so, show it.
		Notify o.Tostring()
	EndIf
End Function