How can I write my Mathematica code so that it resumes at a specific place if any Message is displayed during the execution of an expression? For example, in Visual Basic for Applications there's on error resume next, or on error goto. I'd like also to be able to log the issue in a list so I can reproduce and correct the problem later.

  • 7
    $\begingroup$ You've looked at Check, Catch,Throw and CheckAbort ? [ Whispers: oh and there is also Goto ]. $\endgroup$ Nov 14, 2012 at 17:35
  • $\begingroup$ Check this too $\endgroup$
    – Rojo
    Nov 14, 2012 at 17:36
  • $\begingroup$ Check is what are I need, and the other possibilities are interesting also, thanks. $\endgroup$
    – faysou
    Nov 14, 2012 at 21:14
  • $\begingroup$ @image_doctor as your comment answers the question can you please write a proper answer ? $\endgroup$
    – faysou
    Feb 1, 2013 at 11:30
  • $\begingroup$ @image_doctor, maybe you can answer the question now? :) $\endgroup$ Apr 28, 2013 at 16:24

1 Answer 1



Check[expr, failexpr] evaluates expr, and returns the result, unless messages were generated, in which case it evaluates and returns failexpr.

Check[expr, failexpr, {s1::t1, s2::2, …}] checks only for the specified messages.

Check[expr, failexpr, "name"] checks only for messages in the named message group.


CheckAbort[expr, failexpr] evaluates expr, returning failexpr if an abort occurs.

Other information that may prove useful:


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.