MathGroup Archive 2012

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

Search the Archive

Abort computation on any message

  • To: mathgroup at
  • Subject: [mg124887] Abort computation on any message
  • From: Szabolcs <szhorvat at>
  • Date: Fri, 10 Feb 2012 05:59:12 -0500 (EST)
  • Delivered-to:

Messages are never fatal in Mathematica, regardless of whether they indicate errors, warnings or they're just informative.  Evaluations continue even after messages are generated.

Question: How can I get Mathematica to abort immediately as soon as a message is generated?

I need the following behaviour: 

  1. if a message would be printed, always abort.
  2. if no message would be printed, don't abort.
  3. do print the first message so I have a hint about what went wrong
  4. the mechanism should work with parallel computations and should abort the full evaluation (i.e. main kernel and all parallel kernels)

Difficulties are caused by the many ways to control message printing:  On/Off, Quiet, etc.  My code does use Quiet, but I am quieting only certain messages.

I have already asked this here:

but the two answers I got (at the time of writing this) do not completely satisfy the requirements from above.

I found an older MathGroup thread about this, which also doesn't solve the problem completely:

  • Prev by Date: Re: Something other than PlotStyle to change look of graphs
  • Next by Date: Run external programs in parallel on OSX
  • Previous by thread: Re: Baffled by FindMinimum
  • Next by thread: Re: Abort computation on any message