5

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.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
faysou
  • 10,999
  • 3
  • 50
  • 125

1 Answers1

4

Check:

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:

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

Other information that may prove useful:

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371