Wolfram Research

Function Repository Resource:

QuietCheck (1.0.0) current version: 1.0.1 »

Source Notebook

Use Check and Quiet, conveniently combined into one function

Contributed by: Sjoerd Smit

ResourceFunction["QuietCheck"][expr,failexpr]

is equivalent to Check[expr,failexpr] but does not print any messages.

ResourceFunction["QuietCheck"][expr,failexpr,{s1::t1,s2::t2,}]

only checks against and quiets the given list of messages.

Details and Options

ResourceFunction["QuietCheck"] has attribute HoldAll.
ResourceFunction["QuietCheck"] does not test for messages that have been switched off using Off or by uses of Quiet that occur inside it.
In ResourceFunction["QuietCheck"][expr,failexpr,"name"], possible named message groups are given by $MessageGroups.
Explicit message names of the form s::t can be mixed with named message groups.

Examples

Basic Examples (3) 

Return $Failed when messages are encountered but do not show them:

In[1]:=
ResourceFunction["QuietCheck"][1/0, $Failed]
Out[1]=

Only check for specific messages:

In[2]:=
ResourceFunction["QuietCheck"][{}[[1]], $Failed, Part::partw]
Out[2]=

Messages not included in the third argument to QuietCheck are still displayed:

In[3]:=
ResourceFunction["QuietCheck"][1/0, $Failed, Part::partw]
Out[3]=

Publisher

Sjoerd Smit

Version History

  • 1.0.1 – 21 July 2023
  • 1.0.0 – 07 August 2019

License Information