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

exceptionallyComposeAsync (Future method)

Last update:
May 18, 2026
If this Future fails, runs a recovery function on the async executor that returns another Future. On success, the result passes through.

Description

exceptionallyComposeAsync is the async counterpart to exceptionallyAsync. Use it when recovery itself requires an asynchronous step.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.exceptionallyComposeAsync(function)

Parameters

ParameterDescription
functionRequired. A function that takes the exception and returns a Future for recovery.

See also

Example

Nested async recovery and chained recovery (from product tests).

 <cfscript>
    future = runAsync(function() { throw("error"); });
    sleep(200);
    recovered = future.exceptionallyComposeAsync(function(error) {    return runAsync(function() { return "recovered_async"; });});
    writeOutput(recovered.get()); // recovered_async
    // Chained recovery when inner recovery fails:
    future2 = runAsync(function() { throw("first error"); });
    sleep(200);
    recovered2 = future2    .exceptionallyComposeAsync(function(error) {        return runAsync(function() { throw("second error"); });    })    .exceptionallyComposeAsync(function(error) {        return runAsync(function() { return "final_recovery"; });    });
    writeOutput(recovered2.get()); // final_recovery
</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