This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Built-in Functions / New in Version 3.0 / Programming  /

  • Catch[ expr ] returns the argument of the first Throw generated in the evaluation of expr.
  • Catch[ expr , form ] returns value from the first Throw[ value , tag ] for which form matches tag.
  • Catch[ expr , form , f ] returns f [ value , tag ].
  • Catch[ expr , ... ] always returns the value of expr if no Throw was generated during the evaluation.
  • form can be any expression, and is often a pattern.
  • tag in Throw[ value , tag ] is re-evaluated every time it is compared to form.
  • See the Mathematica book: Section 2.5.9.
  • See also: Check, CheckAbort.

    Further Examples

    This function throws overflow if its argument is greater than 10.


    g[20] throws overflow, which is returned as the value of the enclosing Catch.



    In this case, overflow is not generated, and the Catch has no effect.