Re: How to use error message return values
- To: mathgroup at smc.vnet.net
- Subject: [mg37758] Re: How to use error message return values
- From: daiyanh at earthlink.net (Daitaro Hagihara)
- Date: Mon, 11 Nov 2002 05:10:32 -0500 (EST)
- References: <aqld31$bhn$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <aqld31$bhn$1 at smc.vnet.net>, Andrzej Kozlowski <andrzej at tuins.ac.jp> wrote: >One possibility: > >inv[M_, p_] := Block[{$Messages = {}}, Check[Inverse[M, Modulus -> p], >"Your > matrix has no inverse modulo " <> ToString[p] <> ". Use another >one."]] Hmmm...This Check function does not "halt" the computation... In[]:= Check[ Inverse[{{5, 5}, {5, 5}}, Modulus -> 26]; Print[123], $Failed] --> Inverse::modp: Value of option Modulus -> 26 should be a prime number. 123 Out[]= $Failed Some more test: Unprotect[Message]; Message[Inverse::modp,__]:=Throw[$Failed]; Protect[Message]; Catch[ Inverse[{{5, 5}, {5, 5}}, Modulus -> 26]; 123 ] --> 123 So Throw doesn't work either. Likewise for Return as well. DH