PtProtectCallbacks

PtProtectCallbacks — protects code from callback errors.

Syntax

PtProtectCallbacks (state)

		

Arguments

state

The protection state: t or nil.

Returns

1 if the state is t, 0 if it is nil.

Description

This function is designed to be used in code that surrounds callbacks. As such, it protects code related to those callbacks from possible errors. If, for example, an error occurs, the error will be thrown but the callback function will complete safely. This means that if more than one error occurs in processing a callback, only the first error will be reported.

Of course, if this function is not called and errors occur, they will all be reported. However, the callback will terminate early, which could cause failures in subsequent Photon calls. This is especially noticeable if the error causes the drawing state to get damaged, so that subsequent draws do not complete properly. You will find areas of the screen are not redrawn, or are redrawn with the wrong data. The effect is localized to your program, though, so it won't harm the underlying Photon environment.