Error Handling?

BlitzMax Forums/BlitzMax Programming/Error Handling?

Arcadenut(Posted 2005) [#1]
Will BlitzMax have anything like Try...Catch error handling? I hate it when my app blows up and they get an "Illegal Memory Address" in Blitz Basic. If I could trap specific areas of my code, it would be a little cleaner for me to shut the game down gracefully.

Just makes it a little more professional.


BlitzSupport(Posted 2005) [#2]
It already does -- see the Language/Exceptions part of the manual, or Commands/Index/Catch.

Here's the example (not sure if you have Max at this point):

Rem
Catch defines an exception handler following a Try..EndTry Block.
End Rem

Try
	Repeat
		a:+1
		Print a
		If a>20 Throw "chunks"
	Forever
Catch a$
	Print "caught exception "+a$
EndTry



Robert(Posted 2005) [#3]
I suggest that you disable Try / Catch blocks when building in debug mode, otherwise Try / Catch can mask real bugs in your code.