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

handle

Last update:
May 18, 2026
Runs a handler on the completing thread when this Future finishes. The handler receives both the value and the error (one is null) and returns a single new value.

Description

handle is an instance method on a CFML Future. When this stage completes, your function runs on the completing thread. It receives the result (or null if the stage failed) and the error (or null if the stage succeeded). It returns one replacement value for the next stage. That makes it useful for graceful degradation without duplicating try or catch logic at every call site.
This is the synchronous counterpart to handleAsync.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.handle(function)

Parameters

ParameterDescription
functionRequired. A function (value, error) that returns the next value for the chain.

Example

Append a suffix on success; substitute a string on failure.

<cfscript>
    future = runAsync(function() { return "success"; });
    handled = future.handle(function(value, error) {
        return isNull(error) ? value & "_handled" : "error_handled";
    });
    writeOutput(handled.get()); // success_handled
</cfscript>
      

See also

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