Executing a Function On a critical case

BlitzMax Forums/BlitzMax Programming/Executing a Function On a critical case

Hardcoal(Posted 2013) [#1]
Is there a way to lunch a specific code before
Your application crashes lets say because of a null object.


TomToad(Posted 2013) [#2]
There is Try and Catch, but will only catch null objects in debug mode.

SuperStrict

Type TMyType
	Field a:Int
	Field b:Int
End Type

Local MyType:TMyType = Null

Try
	MyType.a = 10
Catch ex:Object
	Print ex.tostring()
End Try


If you want something to work in release mode, then you will need to create your own error handler.
SuperStrict

Type TMyType
	Field a:Int
	Field b:Int
End Type

Local MyType:TMyType = Null

If MyType
	MyType.a = 10
Else
	Print "Error: MyType is null"
End If