How can I show a Runtime error?

BlitzMax Forums/BlitzMax Programming/How can I show a Runtime error?

Great. I've made a global var called DebugInt that you can set anywhere in your code so that if it crashes unexpectedly, the number is shown so you at least have an idea where it went wrong. We did this for our Client/Server Delphi database application Merlio32 and it was really useful.

' -----------------------------------------------------------------------------
'General error handling
' -----------------------------------------------------------------------------
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


Thanks again Budman. Now my framework will be able to give really good debug info back in the event of a crash.