Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2012

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

Search the Archive

Re: Abort computation on any message

  • To: mathgroup at
  • Subject: [mg124889] Re: Abort computation on any message
  • From: Fred Simons <f.h.simons at>
  • Date: Sat, 11 Feb 2012 06:34:07 -0500 (EST)
  • Delivered-to:
  • References: <>

A very long time ago I think I saw something like the following:

Message[x___] /; (Print["Message"[x]]; True) := Abort[]

In[4]:= 1/0
During evaluation of In[4]:= Message[Power::infy,1/0]
Out[4]= $Aborted

I am not sure this trick will satisfy all your conditions.

Kind regards,

Fred Simons
Eindhoven University of Technology

On 10-2-2012 11:59, Szabolcs wrote:
> 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: Re: Why does the order of down values come back?
  • Previous by thread: Abort computation on any message
  • Next by thread: Re: Abort computation on any message