9
$\begingroup$

Can I Quiet my procedure and still get messages info from inner EvaluationData?

This works fine:

EvaluationData[1/0]["MessagesExpressions"]
{Hold[Message[Power::infy, 1/0]]}

but I don't want to propagate messages up so I use Quiet:

Quiet @ EvaluationData[1/0]["MessagesExpressions"]
{}

I didn't expect that since Quiet is outer to EvaluationData.

It seems inconsistent with respect to Check behavior:

Quiet @ Check[1/0, err]
err

Here inner messages are captured correctly.

What am I missing?

$\endgroup$

1 Answer 1

8
$\begingroup$

The definition of EvaluationData can be read with PrintDefinitions from the GeneralUtilites package, wherein we see:

handleMessage = logMessage[$messages, #1] &;
Internal`AddHandler["Message", handleMessage];

The definition of logMessage includes:

CloudObject`Private`logMessage[bag_, Hold[Message[___], False]] := Null;

When you use Quiet the message expression form Hold[_Message, False] is producted, so logMessage is expressly omitting these messages from its collection.


To get all messages as you apparently want you can replace that definition:

EvaluationData[1]; (* preload - do not remove *)

CloudObject`Private`logMessage[bag_, Hold[Message[___], False]] =.;

self : CloudObject`Private`logMessage[_, Hold[_Message, False]] := 
  ReplacePart[Unevaluated@self, {2, -1} -> True]


Quiet @ EvaluationData[1/0]["MessagesExpressions"]
{Hold[Message[Power::infy,1/0]]}
$\endgroup$
4
  • $\begingroup$ Thanks for investigation. Don't you think it should work like Check out of the box? $\endgroup$
    – Kuba
    Commented Jul 7, 2017 at 9:53
  • $\begingroup$ @Kuba Plainly the designer(s) thinks it should not or that definition would not have been included. Check is a programmatic control and it makes sense to bypass the Quiet mechanism, as otherwise adding Quiet would break many programs using Check. EvaluationData seems to just be a reporting function and I think it makes sense that Quiet has the effect that it does on it. Were it my choice it would be an option of EvaluationData. $\endgroup$
    – Mr.Wizard
    Commented Jul 7, 2017 at 9:56
  • 2
    $\begingroup$ I see, well clearly it is another choice I find unexpected. If I wanted clean EvaluationData I'd have done EvaluationData @ Quiet .... There is no notion of 'raporting function' but nevertheless Check would qualify there too. All that of course are subjective notes. God, isn't that obvious that there was a design choice that was not obvious and it should be emphasized in documentation? Why can't I predict the code I'm writing? Am I unable to learn WL or is L premature? $\endgroup$
    – Kuba
    Commented Jul 7, 2017 at 10:02
  • 7
    $\begingroup$ @Kuba I sympathize with your frustration. Directorial emphasis seems to be on an ever-increasing number of functions with neither the development (performance) nor the documentation to support it. Mathematica has become "bloatware." It saddens me. :-( $\endgroup$
    – Mr.Wizard
    Commented Jul 7, 2017 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.