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 withNOT.IF TaskFailed(h) = 1is always false.= TRUEworks.- Str(TaskFailed(h)) gives
trueorfalse. - A handle that never received a task (still
NULL) stops the program withBASIC 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 throughAWAITTASKorTaskResult()inside aTRY.
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 0In the manual : The game loop and tasks