Help says Messages[symbol] gives all the messages assigned to a particular symbol. These are called message identifiers per help:

Message names always consist of a function name and message identifier separated by a double colon (::).

I wanted to find all possible error/warning message identifiers that say the function DSolve can throw. Such as DSolve::dvlen and so on without having to search for them one by one in different help pages. It will also be nice to know which is an error message vs. a warning message if possible.

But Messages[DSolve] returns empty, because help says Typically, for system commands, messages are only loaded when they are required:

Is there a way, may be using MathematicalFunctionData ? or in other ways to obtain complete list of such messages?

V 12.1 on windows.




  • 4
    $\begingroup$ There's also the thing that some messages are really attached to General so they cannot be listed using Messages[symbol]. $\endgroup$ – Szabolcs May 27 at 6:19
  • 2
    $\begingroup$ When I wrote up searchMessages[], I used FileNameJoin[{$InstallationDirectory, "SystemFiles", "Kernel", "TextResources", "English", "Messages.m"}] as the primary source. Of course, not all the messages used by Mathematica are in there, for some reason. And yes, Szabolcs is correct that any message associated with General can be generically associated with other functions: the message you get when evaluating 1/0 is attached to Power, but is actually from General::infy. $\endgroup$ – J. M.'s discontentment May 27 at 7:33
  • 2
    $\begingroup$ My wish is that such a list of messages is placed somewhere on top of a documentation page for a symbol. How can you handle exceptions without knowing what's going to be thrown at you? $\endgroup$ – Kuba May 27 at 9:09

You could do something like this:

ListMessages[sym_Symbol] := Module[{},
  FileNameJoin[{System`Private`$MessagesDir, $Language,"Messages.m"}] // Get // Once; 
    Block[{MessageName}, Grid[Messages[sym] /. RuleDelayed -> List /. 
      MessageName[a_, b_] :> (ToString[a] <> "::" <> ToString[b]) /. 
      HoldPattern -> Identity, Alignment -> {Left}]]

And then



enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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