TryCatch
Revision as of 20:01, 13 February 2012 by Amalthea (Talk) (Protected Template:TryCatch: Highly visible template: metatemplate ([edit=sysop] (indefinite) [move=sysop] (indefinite)))
[view] [edit] [history] [] File:Template-info.png Template documentation
This metatemplate simplifies implementing fallback output if an error occurs due to incorrect input. It returns the first parameter if it does not contain an error (using the #iferror parser function), and the second parameter (or the empty string) otherwise.
Usage
-
{{TryCatch|{{#expr: 1/2}}|Incorrect input}}→ 0.5 -
{{TryCatch|{{#expr: 1/0}}|Incorrect input}}→ Incorrect input
See also
- {{Error}}: template to signal an error
- Help:Extension:ParserFunctions
| The above documentation is transcluded from TryCatch/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories and interwikis to the /doc subpage. Subpages of this template. |
