6

For example, when I use LinearSolve, an error message might be encountered:

LinearSolve::luc: Result for LinearSolve of badly conditioned matrix `1` may contain significant numerical errors.

where `1` is to be filled with the detailed badly-conditioined matrix.

The problem is that when that matrix is very big, then a very large error file will be generated. So is it possible to suppress the latter part and just keep the error name LinearSolve::luc printed out?

1 Answers1

5
<< GeneralUtilities`

WithMessageHandler[
 1/0, Print@#["MessageTemplate"] &
]

enter image description here

Does it fit your needs?

Keep in mind that with this handler the message isn't a message anymore so you can't Check it etc.

Kuba
  • 136,707
  • 13
  • 279
  • 740
  • Not only "you can't Check it," but internal built-in code can't either, right? (I've never used WithMessageHandler, except to play with.) – Michael E2 Aug 22 '20 at 13:34
  • Wait: WithMessageHandler[ Check[1/0, "Fudge!"], Print@#["MessageTemplate"] &] seems to work fine. – Michael E2 Aug 22 '20 at 13:44