Failure

Failure["tag",assoc]

represents a failure of a type indicated by tag, with details given by the association assoc.

Details

  • Failure[]["prop"] extracts a property from a Failure object. Failure[][{key1,key2,}] extracts a list of values. »
  • Failure[]["Properties"] returns a list of available properties. »
  • The association assoc typically includes:
  • "MessageTemplate"a string template for a message
    "MessageParameters"parameters to use for the message template
  • The parameters are effectively inserted into the message template using TemplateApply.
  • With the entry "MessageTemplate":>symb::name a message name can be stored for use when a message is generated.
  • Failure is generated by Interpreter and related functions. Possible tags in this case are "InterpretationFailure", "RestrictionFailure", "ConditionFailure", and "ConnectionFailure".

Examples

open allclose all

Basic Examples  (2)

A typical way in which Failure is generated:

Show the underlying structure:

Manually construct a failure:

Scope  (10)

Basic Uses  (6)

Create a Failure using only a tag:

Use a tag and a message:

Use a template with positional parameters:

Indicate a failure using a StringTemplate:

Indicate a failure using MessageName:

Failure can contain metadata:

Properties  (4)

Get a list of all the available properties:

Extract the "Input" property:

Extract the message template, name and parameters:

Extract the message template without evaluating it:

Extract the actual error message:

Properties & Relations  (4)

Use ToString to get the formatted message:

This is equivalent to the "Message" property:

Failure is returned by functions like SendMail and EntityPrefetch:

For these functions, the opposite of Failure is Success:

Failure expressions are FailureQ:

Using an Association with Rule will embed the evaluated expression into the Failure expression:

Use RuleDelayed to prevent evaluation:

Neat Examples  (1)

Generate a dataset with all the properties of a Failure expression:

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

Text

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

CMS

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

APA

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

BibTeX

@misc{reference.wolfram_2024_failure, author="Wolfram Research", title="{Failure}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Failure.html}", note=[Accessed: 23-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_failure, organization={Wolfram Research}, title={Failure}, year={2014}, url={https://reference.wolfram.com/language/ref/Failure.html}, note=[Accessed: 23-November-2024 ]}