Tag Info

New answers tagged


In version 10 or later, we can use EvaluationData. EvaluationData[1/0; 0^0] Behind the scenes, this uses handlers, like in my first answer.


The down values of the built-in symbol MessageList track all the messages emitted in a given kernel session. It can be used to get the count you want by evaluating count := Total[Length /@ DownValues[MessageList][[All, 2]]]; Then each time you evaluate count, you will the current total of the messages emitted so far in your kernel session. Here is an ...


sessionCount = 0; Check[1/0, sessionCount++; $Failed] & /@ Range[3] // Quiet; sessionCount (* 3 *) Check[1/0, sessionCount++; $Failed] & /@ Range[5] // Quiet; sessionCount (* 8 *)


You can do this using Mathematica's built-in message system; also, I'd suggest looking through Mathematica's package development documentation and tutorials, as these commonly go hand-in-hand; here is one starting place. As for the specific question, here is an example: MyFunction::argerr = "Bad argument given to MyFunction: `1`"; MyFunction[x_Integer] := ...

Top 50 recent answers are included