There is good explanation available for error handling on this and similar links. Here there is information on handling inappropriate input arguments and handling unprocessed functions using $Failed
. But it is much of incomplete because I want to catch error message and according to that display some specific message. For example if I get
Integrate::idiv: Integral of E^n does not converge on {1,\[Infinity]}. >>
Than I want to display some specific message in words which is possible if I can capture this message and extract from it or if Mathematica returns some error code associated.
Is there some better technique available than just using $Failed
everywhere ?
Internal`AddHandler["Message", . . .]
may be exactly what you're looking for. $\endgroup$Throw
to find out which error it was. No time right now do decribe this in more detail, but it is a logical extension of the exception-based method I described in the link you cited. You can also look at the source code ofRLink
to see this applied in practice. $\endgroup$