Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Merge nested failure information
Nested failures can occur when multiple instances of Enclose/Confirm are nested inside each other:
In[1]:= |
Out[1]= |
The "Information" property of the Failure object only holds the outer message:
In[2]:= |
Out[2]= |
FlattenFailure makes the messages more readable and finds the messages embedded inside deeper Failure objects and puts them in the outer object to make it easy to see the trace of everything that went wrong:
In[3]:= |
Out[3]= |
In[4]:= |
Out[4]= |
Use the Identity handler to extract all internal Failure objects and display them:
In[5]:= |
Out[5]= |
Anything that's not a Failure object will simply be returned:
In[6]:= |
Out[6]= |
In[7]:= |
Out[7]= |
The handler can also be a property to extract from a Failure object:
In[8]:= |
Out[9]= |
Use FlattenFailure before functions with Enclose to automatically collect all messages as they accumulate:
In[10]:= |
In[11]:= |
Out[11]= |
In[12]:= |
Out[12]= |
In[13]:= |
Out[13]= |
If the info messages themselves are lists, the default handler will flatten them out as well:
In[14]:= |
Out[15]= |
Use an inert wrapper to keep the lists intact:
In[16]:= |
Out[16]= |
Duplicate messages will be shown only once:
In[17]:= |
Out[18]= |
Use the Identity handler to catch all the different failure objects:
In[19]:= |
Out[19]= |
This work is licensed under a Creative Commons Attribution 4.0 International License