Handling Errors

BlitzMax Forums/BlitzMax Programming/Handling Errors

Is there a way to put an error handling system into your program? I'd like to be able to handle errors that are thrown by the debugger/Windows in my own code.

You can use Assert.

You can use Assert.

Only in Debug mode - so fine for testing but not as useful for catching issues in Release mode.

You might look at Try/Catch with Exceptions. There is some documentation about it in the Help section.

That's good, but I mean like when the debugger throws a "UME" error, I want to be able to print it out in my graphics window, rather than the message box appearing. Is that possible?

UME?

Unhandled Memory Exception

Im not sure, but maybe you can use this functions?:

Function Notify( text$,serious=False )

Function Confirm( text$,serious=False )

Function Proceed( text$,serious=False )


They are in the manual.

Strict
Graphics 800 , 600

While Not KeyHit(key_escape) 
	For Local i = 10 To 0 Step - 1
		Cls
		Local a:Float
	
		Try
			a = 10/i
		Catch a:Object
			Cls
			DrawText "ERROR: " + a.tostring() , 0 , 0
			DrawText "hit any key to exit...",0,20
			Flip
			WaitKey() 
			End
		EndTry
		
		DrawText "10/"+i+"= " + a , 0 , 0
		Flip
		Delay 200
	Next
Wend