Whatever message this page gives is out now! Go check it out!

handleAsync (Future method)

Last update:
May 18, 2026
When this Future completes, runs a function on the async executor that can return a new value for both success and failure cases.

Description

Unlike whenCompleteAsync, handleAsync can recover from errors by returning a value from the handler. The handler receives (value, error) and returns the value the next stage should use.

Returns

A new Future.

Category

Function syntax

future.handleAsync(function)

Parameters

ParameterDescription
functionRequired. A function (value, error) that returns the next value. Test for isNull(error) to branch.

See also

Example

Recover from a thrown error.

 <cfscript>
    future = runAsync(function() { throw("error"); });sleep(200);
    handled = future.handleAsync(function(value, error) {    return isNull(error) ? value : "recovered";});
    writeOutput(handled.get()); // recovered
</cfscript>
      

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page