Re: Abort computation on any message
- To: mathgroup at smc.vnet.net
- Subject: [mg124889] Re: Abort computation on any message
- From: Fred Simons <f.h.simons at tue.nl>
- Date: Sat, 11 Feb 2012 06:34:07 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201202101059.FAA00840@smc.vnet.net>
A very long time ago I think I saw something like the following: Unprotect[Message]; 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: > > http://mathematica.stackexchange.com/q/1512/12 > > 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: > > http://forums.wolfram.com/mathgroup/archive/2005/Apr/msg00127.html > >
- References:
- Abort computation on any message
- From: Szabolcs <szhorvat@gmail.com>
- Abort computation on any message