confirms that expr is not considered a failure, otherwise throwing an error to the nearest surrounding Enclose.
evaluates info and includes its value in the thrown error if expr is not confirmed.
uses the specified tag for any thrown errors.
- Confirm[expr,…] returns expr if expr is successfully confirmed.
- Confirm[expr,…] considers expr a failure and throws an error if expr has any of the following forms:
Failure[…] Missing[…] $Failed $Canceled $Aborted
- Confirm is dynamically scoped when given a tag. Otherwise, it is lexically scoped. »
- The default value of info is Null.
- expr is wrapped in a Failure before it is thrown unless info is Null and expr is a Failure from a previous confirmation function. »
- Failure objects generated by Confirm include the following fields:
"Information" info from Confirm[expr,info,…] "Expression" expr from Confirm[expr,…]
- Values of these fields can be extracted using failure["prop"] or directly through Enclose[expr,"prop"].
Examplesopen allclose all
Basic Examples (2)
Confirm stops evaluation and returns to the matching Enclose when it throws an error:
info is only evaluated when expr cannot be confirmed:
Create a function that calls Confirm with a tag so that it can be caught dynamically:
If no tag is given, Confirm is lexically scoped:
Failures are wrapped in a Failure before they are thrown, unless they were thrown from another confirmation function:
This behavior is overruled when info is not Null:
Wolfram Research (2020), Confirm, Wolfram Language function, https://reference.wolfram.com/language/ref/Confirm.html.
Wolfram Language. 2020. "Confirm." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Confirm.html.
Wolfram Language. (2020). Confirm. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Confirm.html