I have found that despite Mathematica's numerous updates, each of which have added much functionality, one fundamental issue remains unaddressed: The unresponsiveness of the UI when I make a mistake (specifically, this is in Mac OS X, but the problem may exist in the other OSes). The problem has existed since at least Mathematica 4, and still exists in Mathematica 8.
If, for instance, I define a variable f through a function, and something goes wrong in that function, the error often cascades out of control, and every single bit of code that uses f subsequently will dump out dark orange colored error messages of the form Function::errorname : Error description here. If this is in a loop with thousands of iterations, the UI can be completely unresponsive, even to repeated presses of Command + Period or quitting the kernel via the menubar. Often times, Mathematica will eat up massive amounts of memory when this happens and eventually crash.
I was just wondering if people had a general strategy for avoiding this situation, aside from assiduous error checking at every stage in a program to ensure that outputs are always reasonable. My desired behavior would be to have Mathematica abort its currently-running calculation if even a single error message is produced (unless I turn them off using Off), but I have no idea if this is possible without explicit, repeated checks in the code to see if an error message has been thrown. Alternatively, if there is a way to say dump error messages to a file rather than attempting to store their contents within the notebook, that would perhaps avoid the memory overflows that often cause Mathematica to fail.
Does anyone have an ideas on how to alleviate this issue? Thanks!
Edit: One work-around seems to be changing the "KernelMessageAction" option within the MessageOptions folder to "PrintToConsole" instead of just "Print". This dumps the error messages to a separate window. The advantage of doing this is that the window has a "Delete All Messages" button which you can click to clear the messages from memory. I am not sure if this addresses the underlying problem of the UI becoming unresponsive, however.