Conditional Error Trapping

Error Trapping is one of those topics that are immune from criticism, but let's assume that our aim when developing an application is to ensure that the ultimate end user is never confronted with an APL error message.

Each implementation of APL offers its own approach to error trapping - it's one of those things that has never really been standardised.  Indeed, even within a single vendor's product we can sometimes find more than one way to deal with errors.

In this page there's no real attempt to consider the merits of the different implementations, it just looks at one mechanism that has been present in Dyalog APL for a few years.

However, let's drive two stakes into the ground...


Here's an example of how the second objective can be achieved in Dyalog APL...

     ∇ z←a foo w;⎕TRAP
[1]   ⍝ Demonstrate optional error-trapping
[2]    :Trap #.TrapsOn/0
[3]        z←aśw
[4]    :Else 
[5]        z←'NINCOMPOOP ERROR' 
[6]    :EndTrap 
     ∇  
      TrapsOn←1 ⍝ For the end-user
      2 foo 0
NINCOMPOOP ERROR
      TrapsOn←0 ⍝ For the developer
      2 foo 0
DOMAIN ERROR
foo[3] z←aśw
      ∧

Notes:


Page last updated 26 November 2008.
Copyright © Dogon Research 2008.