evaluates expr, returning failexpr if an abort occurs.

Details and Options


open allclose all

Basic Examples  (1)

Catch an abort in a part of a computation allowing the rest of it to continue:

Scope  (3)

Use CheckAbort inside AbortProtect to detect aborts:

The return value may depend on the function that generated the abort:

Use PropagateAborts to control whether aborts continue or terminate after CheckAbort:

Use CheckAbort inside TimeConstrained to select which parts are skipped if the limit is reached:

This can also be done with MemoryConstrained:

Options  (2)

PropagateAborts  (2)

The default setting, Automatic, does not propagate user-initiated aborts outside of CheckAbort:

Use the setting PropagateAbortsTrue to force the abort to persist past the CheckAbort:

Aborts created by TimeConstrained are by default propagated:

Use the setting PropagateAbortsFalse to prevent the abort from persisting:

Aborts created by MemoryConstrained are similar:

Properties & Relations  (5)

The evaluation of the second argument cannot be interrupted once begun:

The argument is effectively wrapped in AbortProtect:

CheckAbort enables and detects aborts even if enclosed within AbortProtect:

While the computation inside the CheckAbort is terminated, AbortProtect runs to completion:

A nested AbortProtect will delay an abort but not prevent it from being detected by CheckAbort:

If an abort is already active when CheckAbort begins, the first argument will not be evaluated:

CheckAbort can be used to perform cleanup if a computation is interrupted:

$myFlag is set to False even for inputs that produce an abort:

WithCleanup accomplishes this same goal with significantly less code:

Wolfram Research (1991), CheckAbort, Wolfram Language function, (updated 2022).


Wolfram Research (1991), CheckAbort, Wolfram Language function, (updated 2022).


Wolfram Language. 1991. "CheckAbort." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022.


Wolfram Language. (1991). CheckAbort. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_checkabort, author="Wolfram Research", title="{CheckAbort}", year="2022", howpublished="\url{}", note=[Accessed: 13-July-2024 ]}


@online{reference.wolfram_2024_checkabort, organization={Wolfram Research}, title={CheckAbort}, year={2022}, url={}, note=[Accessed: 13-July-2024 ]}