Menu

Reference / Async

failure()

function
function failure(): string

Where the last failure came from.

Names the task that raised it, the file:line it was spawned at, and the scope it sat in. A child's exception reaches you carrying the trace of whoever joined it, and the task that actually failed is not in that trace; this is recorded beside the exception, at the moment of failure. It names only the first real failure: the cancellation wave after it is not blamed on the tasks that were swept up.

try { async(fn() => work()); }
catch (\Throwable $e) { fwrite(STDERR, Async\failure()); }
// task #7 "worker" at jobs.php:31 raised RuntimeException: no such row
//   in scope near jobs.php:12

Returns

string — the report, or '' when the last run did not fail; reset by every async()

See also: dump, Task::named

View source