This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Input and Output / Messages  /
Check

  • Check[ expr , failexpr ] evaluates expr, and returns the result, unless messages were generated, in which case it evaluates and returns failexpr.
  • Check[ expr , failexpr , :: , :: , ... ] checks only for the specified messages.
  • Check has attribute HoldAll.
  • Check tests only for messages that are actually output. It does not test for messages that have been suppressed using Off.
  • See the Mathematica book: Section 2.8.21.
  • See also: MessageList, $MessageList, Message, Indeterminate, TimeConstrained, CheckAbort.

    Further Examples

    Evaluating 0^0 produces a message, so the second argument of Check is returned.

    In[1]:=

    0
    Power::indet: Indeterminate expression 0 encountered.

    Out[1]=

    In[2]:=

    Log::argt: Log called with 3 arguments; 1 or 2 arguments are expected.

    Out[2]=