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?

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]]}
  • Thanks for investigation. Don't you think it should work like Check out of the box? – Kuba Jul 7 '17 at 9:53
  • @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. – Mr.Wizard Jul 7 '17 at 9:56
  • 1
    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? – Kuba Jul 7 '17 at 10:02
  • 6
    @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. :-( – Mr.Wizard Jul 7 '17 at 10:07

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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