Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Apply a custom handler to messages generated during evaluation
ResourceFunction["WithMessageHandler"][expr,f] evaluates expr, applying f to Failure objects constructed out of messages generated during the evauation. |
Print error message instead of issuing a message:
In[1]:= |
|
Out[1]= |
|
Abort after printing the first message:
In[2]:= |
|
Out[2]= |
|
Collect messages generated during evaluation in a list:
In[3]:= |
|
Out[3]= |
|
Messages processed with WithMessageHandler are shielded from $MessageList and MessageList:
In[4]:= |
|
Out[4]= |
|
In[5]:= |
|
Out[5]= |
|
Compare with the standard evaluation:
In[6]:= |
|
Out[6]= |
|
In[7]:= |
|
Out[7]= |
|
$MessagePrePrint receives only expressions that are included in the text of messages:
In[8]:= |
|
Out[8]= |
|
WithMessageHandler does not see messages that are suppressed, for instance, using Quiet:
In[9]:= |
|
Out[9]= |
|
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License