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

exceptionally

Last update:
May 18, 2026
If this Future completes with an error, runs a recovery function on the completing thread that returns a substitute value. Successful results pass through unchanged.

Description

exceptionally is an instance method on a CFML Future. If this stage completes successfully, the value is forwarded and your function is not used for mapping. If this stage completes exceptionally, your function runs on the completing thread. It receives the exception and returns a recovery value. The method returns a new Future that completes with either the original success value or the recovery value.
This is the synchronous counterpart to exceptionallyAsync. When recovery itself must return another Future, use exceptionallyCompose.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.exceptionally(function)

Parameters

ParameterDescription
functionRequired. A function that accepts the exception from the failed stage and returns a recovery value.

Example

Replace a failed async task with a fallback string.

<cfscript>
    future = runAsync(function() { throw("error"); });
    sleep(200);
    recovered = future.exceptionally(function(error) {
        return "fallback";
    });
    writeOutput(recovered.get()); // fallback
</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