({{, (RefLink[$AssertFunction, paclet:ref/$AssertFunction]) 
specifies a function to apply to assertions that fail.}})

OpenersNotesSection(Spacer1)Details

(RefLink[$AssertFunction, paclet:ref/$AssertFunction]) is applied to (RefLink[Assert, paclet:ref/Assert])[test,…] when test is evaluated and found not to be (RefLink[True, paclet:ref/True]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

You can change the behavior when an assertion fails by assigning to (RefLink[$AssertFunction, paclet:ref/$AssertFunction]). This function throws an exception when an assertion fails:

$AssertFunction = Throw[{##}]& ;

<<ExampleData`FunctionWithAssert`

Here the exception thrown by the assertion function is caught:

Catch[ Compute[ 1.0]]

Off[Assert]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Assert, paclet:ref/Assert])  ▪  (RefLink[Print, paclet:ref/Print])  ▪  (RefLink[Message, paclet:ref/Message])  ▪  (RefLink[On, paclet:ref/On])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Tuning & Debugging, paclet:guide/TuningAndDebugging])}})}})