Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Tag Confirm-type errors with the code that generated the error
ResourceFunction["AddAutomaticConfirmInfo"][symbol] modifies the definition of symbol to add error information to all Confirm-type operations. | |
ResourceFunction["AddAutomaticConfirmInfo"]["symbol"] works with the symbol named "symbol" if it exists. |
Define a function that uses ConfirmBy to validate steps in the computation:
In[1]:= |
The error generated does not mention the symbol y in the original function definition:
In[2]:= |
Out[2]= |
Use AddAutomaticConfirmInfo to populate the third argument of ConfirmBy in the function definition:
In[3]:= |
Out[3]= |
Now the Failure includes useful information:
In[4]:= |
Out[4]= |
Click the Association in the expanded error information to copy the full symbol name and the InputForm of the original code that caused the error:
Define a second function that uses the first one:
In[5]:= |
An error generated by the first ConfirmBy:
In[6]:= |
Out[6]= |
An error propagated up from the first function:
In[7]:= |
Out[7]= |
Use ResourceFunction["FlattenFailure"] to make nested errors easier to inspect:
In[8]:= |
Out[8]= |
Extract the deepest error from the Failure object:
In[9]:= |
Out[9]= |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License