How to trap the last error Message

General APL language issues
Post Reply
User avatar
PGilbert
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

How to trap the last error Message

Post by PGilbert »

In a function you could get an error cause by APL or by .Net, how do you differenciate between the 2 when you want to report the error by using :Trap 0 for exemple ? If you do ⎕EXCEPTION.Message when its empty you get a VALUE ERROR and ⎕DM may not be empty when the error comes from .Net because of a previous error.

Thanks,

Pierre Gilbert
paulmansour
Posts: 431
Joined: Fri Oct 03, 2008 4:14 pm

Re: How to trap the last error Message

Post by paulmansour »

I think []EN should be 90 after a .NET error, and something else otherwise, which should to the trick, unless I am missing something, which I probably am.
User avatar
PGilbert
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to trap the last error Message

Post by PGilbert »

Thanks Paul, here is what works for me. If someone has made something more complete and would like to share...

Code: Select all

 r←GetLastError
 ⍝ Return the Last Error

 :If 90=⎕EN
     r←'EXCEPTION: ',⎕EXCEPTION.Message
 :Else
     r←(1⊃⎕DM),': ',{(~(∧\' '=⍵)∨(⌽∧\⌽' '=⍵))/⍵}(2⊃⎕DM)
 :EndIf


Pierre Gilbert
Post Reply