evaluates expr, returning a Failure if an uncaught error is generated.


returns f[err] for the caught error err.


only catches errors generated with a tag matching tag.


  • Enclose[expr,] returns the value of expr if no error was caught during its evaluation. »
  • Enclose will not catch errors that have already been caught by an inner Enclose.
  • When no tag is provided, Enclose will add tags to all untagged lexically contained confirmation functions. »
  • tag can be any expression including a pattern.
  • Catches errors thrown by Confirm, ConfirmBy, ConfirmMatch, ConfirmQuiet, and ConfirmAssert.
  • Enclose effectively calls Catch with a special tag.
  • The default value of f is Identity.
  • If f is a string, err[f] will be returned instead of f[err]. »


open allclose all

Basic Examples  (2)

Evaluate an expression, exiting as soon as any errors are generated:

Create a robust function:

Scope  (6)

Process an error before returning:

Set f to "Expression" to propagate errors without wrapping in Failure:

The innermost Enclose has precedence:

Use a tag to pass an error to the outer Enclose:

Provide a constant function for f to return a fixed value in the event of any error:

Propagate errors up multiple levels:

Perform multiple confirmations by nesting confirms:

Applications  (3)

Safely call a function that could fail, propagating any errors unchanged:

Propagate missing values while calculating GDP per capita for every country:

Find all polyhedra that have edges between every pair of vertices, ignoring polyhedra where no BoundaryMeshRegion is available:

Possible Issues  (3)

Catch[,_] can intercept errors:

Enclose does not catch expressions thrown by Throw:

If no tag is provided, Enclose lexically replaces symbols like Confirm with lexically tagged variants:

Wolfram Research (2020), Enclose, Wolfram Language function, https://reference.wolfram.com/language/ref/Enclose.html.


Wolfram Research (2020), Enclose, Wolfram Language function, https://reference.wolfram.com/language/ref/Enclose.html.


Wolfram Language. 2020. "Enclose." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Enclose.html.


Wolfram Language. (2020). Enclose. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Enclose.html


@misc{reference.wolfram_2023_enclose, author="Wolfram Research", title="{Enclose}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/Enclose.html}", note=[Accessed: 12-April-2024 ]}


@online{reference.wolfram_2023_enclose, organization={Wolfram Research}, title={Enclose}, year={2020}, url={https://reference.wolfram.com/language/ref/Enclose.html}, note=[Accessed: 12-April-2024 ]}