Function Repository Resource:

GeneratedMessageList

Source Notebook

Get all the messages generated during an evaluation

Contributed by: Jon McLoone

ResourceFunction["GeneratedMessageList"][expr]

evaluates expr and returns the text of any messages generated.

Examples

Basic Examples (1) 

Evaluate an expression, suppressing any messages but returning them as the result:

In[1]:=
ResourceFunction["GeneratedMessageList"][x = 1/0]
Out[1]=

Scope (2) 

Quiet and Off will prevent messages being returned by GeneratedMessageList:

In[2]:=
ResourceFunction["GeneratedMessageList"][Quiet[1/0]]
Out[2]=
In[3]:=
Off[Power::infy];
ResourceFunction["GeneratedMessageList"][1/0]
Out[4]=
In[5]:=
On[Power::infy];
ResourceFunction["GeneratedMessageList"][1/0]
Out[6]=

Message shortens the error parameters:

In[7]:=
FactorInteger[Nest[f, y, 50]];

GeneratedMessageList returns parameters in full:

In[8]:=
ResourceFunction["GeneratedMessageList"][
 FactorInteger[Nest[f, y, 50]];]
Out[8]=

GeneratedMessageList has the same effect as Quiet. No messages will be returned to the Notebook or console, and nested uses of GeneratedMessageList cannot see errors handled by the deeper GeneratedMessageList:

In[9]:=
ResourceFunction["GeneratedMessageList"][{1} + {1, 2}; errors = ResourceFunction["GeneratedMessageList"][1/0]]
Out[9]=
In[10]:=
errors
Out[10]=

Properties and Relations (1) 

GeneratedMessageList provides similar functionality to $MessageList but returns the full message text not just the type of message:

In[11]:=
ResourceFunction["GeneratedMessageList"][1/0]
Out[11]=
In[12]:=
1/0; $MessageList
Out[12]=

Publisher

Jon McLoone

Version History

  • 1.0.0 – 28 June 2022

Related Resources

License Information