6
$\begingroup$

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?

$\endgroup$
2
  • 1
    $\begingroup$ Related: (1512), (20367) $\endgroup$
    – Michael E2
    Aug 22, 2020 at 13:45
  • $\begingroup$ @Αλέξανδρος 我想问一下:你是哪个学校的,看你积分这么高,是川大的吗? $\endgroup$ Sep 14, 2020 at 7:39

1 Answer 1

5
$\begingroup$
<< 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.

$\endgroup$
2
  • $\begingroup$ 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.) $\endgroup$
    – Michael E2
    Aug 22, 2020 at 13:34
  • $\begingroup$ Wait: WithMessageHandler[ Check[1/0, "Fudge!"], Print@#["MessageTemplate"] &] seems to work fine. $\endgroup$
    – Michael E2
    Aug 22, 2020 at 13:44

Your Answer

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

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