Failsafe[f][x1,x2,…]
returns f[x1,x2,…] if none of the xi is considered a failure, and the first failing xi otherwise.
Failsafe
Failsafe[f][x1,x2,…]
returns f[x1,x2,…] if none of the xi is considered a failure, and the first failing xi otherwise.
Details
- Failsafe is typically used to create safe versions of functions that can be applied to many inputs, quietly ignoring bad data. »
- Failsafe[f][x] considers x a failure if x has any of the following forms:
-
Failure[…] Missing[…] $Failed $Canceled $Aborted - Failsafe[f][x1,x2,…] returns the first x1 that is any of the above forms. »
Examples
open all close allBasic Examples (2)
Apply a failsafe version of a function:
Failsafe[f][x]The failsafe version returns the argument unchanged when it is a failure:
Failsafe[f][$Failed]Make a failsafe version of Sqrt that only applies to positive numbers:
Failsafe[Sqrt, Positive] /@ {1, 2, -10, Missing[]}Scope (2)
Map a failsafe function over a list, leaving existing failures unchanged:
Failsafe[f] /@ {1, 2, 3, Missing["NotAvailable"], 6, $Failed, 10}Failsafe functions can be applied to multiple arguments:
Failsafe[f][1, 2, 3]By default, it fails if any arguments are considered a failure:
Failsafe[f][1, Missing[], 3]test and failf are applied to all arguments at once:
Failsafe[Divide, #2 != 0&, g][2, 2]Failsafe[Divide, #2 != 0&, g][2, 0]Applications (1)
Properties & Relations (4)
Failsafe[f][x1,x2,…] returns the first xi that fails:
Failsafe[f][1, $Failed, 2, Missing["NotAvailable"]]Failsafe[f,test][x1,x2,…] applies test to all the xi simultaneously:
Failsafe[f, EchoEvaluation[UnsameQ[##]]&][x, y, z]Failsafe[f,test,failf][x1,x2,…] applies failf to all the xi simultaneously:
Failsafe[f, False&, g][x, y, z]Failsafe can often be approximated with Confirm and Enclose:
{Failsafe[f][x], Enclose[f[Confirm[x]]]}{Failsafe[f][$Failed], Enclose[f[Confirm[$Failed]]]}Related Guides
History
Text
Wolfram Research (2025), Failsafe, Wolfram Language function, https://reference.wolfram.com/language/ref/Failsafe.html.
CMS
Wolfram Language. 2025. "Failsafe." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Failsafe.html.
APA
Wolfram Language. (2025). Failsafe. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Failsafe.html
BibTeX
@misc{reference.wolfram_2026_failsafe, author="Wolfram Research", title="{Failsafe}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/Failsafe.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_failsafe, organization={Wolfram Research}, title={Failsafe}, year={2025}, url={https://reference.wolfram.com/language/ref/Failsafe.html}, note=[Accessed: 12-June-2026]}