Jump to: navigation, search

Difference between revisions of "Template:TryCatch"


m (Protected Template:TryCatch: Highly visible template: metatemplate ([edit=sysop] (indefinite) [move=sysop] (indefinite)))
 
m (1 revision)
 
(No difference)

Latest revision as of 14:36, 23 January 2013


[view] [edit] [history] [purge] Documentation icon 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