How to trap the last error Message

General APL language issues

How to trap the last error Message

Postby PGilbert on Sun Aug 29, 2010 9:59 pm

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
User avatar
PGilbert
 
Posts: 419
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to trap the last error Message

Postby paulmansour on Mon Aug 30, 2010 2:22 am

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.
paulmansour
 
Posts: 370
Joined: Fri Oct 03, 2008 4:14 pm

Re: How to trap the last error Message

Postby PGilbert on Tue Aug 31, 2010 1:02 am

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
User avatar
PGilbert
 
Posts: 419
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest