MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Detecting and handling error messages?

  • To: mathgroup at
  • Subject: [mg24346] Re: Detecting and handling error messages?
  • From: "Dale Horton" <daleh at>
  • Date: Sun, 9 Jul 2000 04:52:51 -0400 (EDT)
  • Organization: Wolfram Research, Inc.
  • References: <8jrbto$>
  • Sender: owner-wri-mathgroup at

The tricky part of using Check is that it doesn't check for messages that
are turned off.
So the question becomes, how do I leave a message on but prevent it from
getting printed.

Fortunately, there's a global variable that controls where these messages
are sent.

"$Messages gives the list of files and pipes to which message output is

{OutputStream["stdout", 1]}

We can use a Block to temporarily suspend the output of all messages.

Block[{$Messages = {}},
  Check[Sin[1, 2], Print["Try again!"]]
"Try again!"


"AES" <siegman at> wrote in message
news:8jrbto$dqe at
> What I'm really after is a simple way of detecting (testing) if errors
> have occurred during the execution of a given Input cell, so I can note
> this and maybe do something, but without actually having the error
> messages be printed to the screen.
> I note that The Mathematica Book on p. 1155 says
>    Off[symbol::tag] switches off a message, SO THAT IT IS NO
>    LONGER PRINTED   (emphasis mine)
> Page 460 says
>    $MessageList    a list of the messages PRODUCED during
>    a particular computation
> Note:  "produced", not "printed" -- ??
> Page 1249 says
>    $MessageList is a global variable that gives a list of the
>    names of messages GENERATED during the evaluation of
>    the current input line
> "Generated" ?=? "produced" ?=? "printed".
> Anyway, as best I can tell by trial and error, messages that have been
> Off[ ]'ed do not appear in $MessageList, and Check[ ] explicitly doesn't
> test for Off[ ]'ed messages.  So is there a way to test if the
> associated errors have or have not occurred?
> Thanks   siegman at

  • Prev by Date: Re: With[{software=Mathematica}, Frustration]
  • Next by Date: RE: Do loop var in deferred assignment
  • Previous by thread: Re: Detecting and handling error messages?
  • Next by thread: Pattern Matching