I have a variety of possible errors in each iteration of a for loop.

If, in one iteration of the loop, there are more than 3 error messages of the same kind, I am happy that the rest are suppressed.

But if errors occur in the next iteration, I need them to be shown.

I tried turning on all error messages after each iteration using On[]; but this turns on a lot of messages which are off by default, which litter my output with red messages that are irrelevant to what I'm doing.

How do I turn on only those error messages which were suppressed? Is there a way to do this without manually catching each suppressed error? Maybe something like On[default], or maybe by previously saving the set of errors which are on, and then resetting back to that state.

  • $\begingroup$ I think what you are looking for is Off[General::stop], that is switch off the message that is shown after the 3 consecutive messages. $\endgroup$ Commented Mar 2, 2020 at 19:21
  • $\begingroup$ That seems like it would just stop telling me that messages are being suppressed. But the messages would continue to be suppressed. So it's not really what I am looking for, unless I'm wrong here. $\endgroup$ Commented Mar 2, 2020 at 20:42
  • $\begingroup$ yes it seems like that, but actually switching that message Off will cause the repeating messages to not be suppressed. Check the documentation ref/message/General/stop for more details. Or just try it out. If you search this site for "General::stop" you will find several questions and answers, some of them might be considered duplicates to your question... $\endgroup$ Commented Mar 3, 2020 at 6:40
  • $\begingroup$ If you want more fine grained control you could manipulate $MessageList as described here $\endgroup$ Commented Mar 3, 2020 at 6:45

1 Answer 1


Steeling from this answer this should do what you are after:

resetMessages[] := (
 $MessageList = {};

You would use it like this:

  Do[1/0, {5}],
  {i, 3}

There will now be shown three messages but no more for the inner loop, but there will be messages for all iterations of the outer loop.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.