specifies a function to apply to assertions that fail.


$AssertFunction
specifies a function to apply to assertions that fail.
Details

- $AssertFunction is applied to Assert[test,…] when test is evaluated and found not to be True.
Examples
Basic Examples (1)
You can change the behavior when an assertion fails by assigning to $AssertFunction. This function throws an exception when an assertion fails:
Here the exception thrown by the assertion function is caught:
Related Guides
Related Workflows
- Get a Stack Trace ▪
- Dynamically Monitor Values of Variables ▪
- Print Intermediate Values of a Variable
History
Text
Wolfram Research (2010), $AssertFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/$AssertFunction.html.
CMS
Wolfram Language. 2010. "$AssertFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/$AssertFunction.html.
APA
Wolfram Language. (2010). $AssertFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/$AssertFunction.html
BibTeX
@misc{reference.wolfram_2025_$assertfunction, author="Wolfram Research", title="{$AssertFunction}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/$AssertFunction.html}", note=[Accessed: 09-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_$assertfunction, organization={Wolfram Research}, title={$AssertFunction}, year={2010}, url={https://reference.wolfram.com/language/ref/$AssertFunction.html}, note=[Accessed: 09-August-2025]}