Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Abort an evaluation as soon as a message is generated
ResourceFunction["AbortOnMessage"][eval] aborts evaluation of eval if a message occurs. | |
ResourceFunction["AbortOnMessage"][eval,quiet] aborts on message but disregards messages in quiet. | |
ResourceFunction["AbortOnMessage"][eval,quiet,listen] forces an abort for any message in listen, even if it is quieted. |
Abort an evaluation as soon as a message occurs:
In[1]:= |
|
Out[1]= |
|
Ignore some messages:
In[2]:= |
|
Out[2]= |
|
Trigger an abort even if a message is suppressed with Quiet:
In[3]:= |
|
Out[3]= |
|
AbortOnMessage will stop an evaluation rather than just suppress additional messages:
In[4]:= |
|
Out[4]= |
|
Use CheckAbort to “catch” aborts and replace with some other expression rather than aborting an entire evaluation:
In[5]:= |
|
Out[5]= |
|
Any messages given in the third argument will take precedence over the second argument:
In[6]:= |
|
Out[6]= |
|
In[7]:= |
|
Out[7]= |
|
This work is licensed under a Creative Commons Attribution 4.0 International License