TaskFailed

Function

Syntax

Tells whether a task stopped on an error.

TaskFailed(<handle>)

Parts

<handle>A task handle: a variable filled by STARTTASK.

Returns

True if the task stopped on an error, false otherwise.

Good to know

  • TaskFailed() answers true or false, not 1 or 0. Test it bare or with NOT. IF TaskFailed(h) = 1 is always false. = TRUE works.
  • Str(TaskFailed(h)) gives true or false.
  • A handle that never received a task (still NULL) stops the program with BASIC value is not a task handle.
  • An error in a task that nobody awaits is reported nowhere else: TaskFailed() is the only way to see it. The message comes back through AWAITTASK or TaskResult() inside a TRY.

Example

t AS TASKHANDLESTARTTASK t, ReloadTRY  AWAITTASK tCATCH e$  Console("caught: " + e$)                  ' caught: out of ammoENDTRYIF TaskFailed(t) THEN Console("failed")     ' failedENDReload:  Wait(0.2)  THROW "out of ammo"RETURN 0
In the manual : The game loop and tasks