Mathematica is a bit unusual as a programming language because it never stops on messages, regardless of whether the message is an error, a warning or just an informative message. It simply prints the message and continues with evaluation. This can cause an avalanche of messages and unpredictable behaviour (e.g. memory may get filled up, bringing the machine to a halt with swapping---this is what happened to me)
Is there a way to immediately abort when any message is generated?
Requirements:
- if a message would be printed, always abort.
- if no message would be printed, don't abort.
- do print the first message so I have a hint about what went wrong
- the mechanism should work with parallel computations and should abort the full evaluation (i.e. main kernel and all parallel kernels)
There are many ways to handle message printing, including On/Off, Quiet, and possibly others (such as setting some system options). The solution should work well with these. I am afraid manually handling all possible situations is too fragile (there's always a chance something got left out).
I found a solution on MathGroup which aborts, but does not print the message.
I suspect there must exist a robust and simple solution because the Debug palette has a "Break on messages" option.