Help / Release / J 4.05 / 13!:0 ]2 Error Capture Implemented
>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Release
13!:0 ]2 Error Capture |
initial writing: 2000-08-02 |
The debug mode 13!:0 now accepts 2 as an argument. 13!:0 ]1 enables error suspension. 13!:0 ]2 does not permit error suspension; instead, where suspension would have happened,
the following phrase is executed:
STACK_ERROR_INFO_base_=: (13!:11 ; 13!:12 ; 13!:13 ; 18!:5) ''
capturing the error number, error text, stack info, and current locale name.
The stack is then cleared, and execution goes into
immediate execution.
Unlike 13!:0 ]1 error suspension, 13!:0 ]2 error capture
does not require a professional key (9!:31).
Example 0:
After an error is encountered in executing 8 foo 'boo boo',
there is no indication of anything untoward, nor is there an error suspension.
However, STACK_ERROR_INFO_base contains the error number,
error text, and stack information at the time of the error.
foo=: 4 : 0 t=. 6!:0 '' x. plus y. ) plus=: 17&|@+ 13!:0 ]2 8 foo 'boo boo' STACK_ERROR_INFO +-+------------------------------+-------------------------------------------- ... |3||domain error: plus |plus[:0] |+----+-+-+-+-------------------------------- ... | | ||plus|3|0|3|17amp;|@+ ... | | || | | | | ... | | || | | | | ... | | |+----+-+-+-+-------------------------------- ... | | ||foo |0|1|3|4 : 0 t=. 6!:0 '' x. plus y. ) ... | | || | | | | ... | | || | | | | ... | | || | | | | ... | | || | | | | ... | | || | | | | ... | | || | | | | ... | | |+----+-+-+-+-------------------------------- ... +-+------------------------------+-------------------------------------------- ... q=: STACK_ERROR_INFO_base_ $q 4 $&.>q ++--+---++ ||30|2 8|| ++--+---++ >0{q 3 >1{q |domain error: plus |plus[:0] 0 2 4 6 7{"1 >2{q +----+-+--------------------------------+-----------+---------------------------+ |plus|0|17&|@+ |+-+-------+| | | | | ||8|boo boo|| | | | | |+-+-------+| | +----+-+--------------------------------+-----------+---------------------------+ |foo |1|4 : 0 t=. 6!:0 '' x. plus y. )|+-+-------+|+--+----------------------+| | | | ||8|boo boo|||t |2000 11 30 9 21 54.811|| | | | |+-+-------+|+--+----------------------+| | | | | ||x.|8 || | | | | |+--+----------------------+| | | | | ||y.|boo boo || | | | | |+--+----------------------+| +----+-+--------------------------------+-----------+---------------------------+
Example 1: The latent expression (9!:29), executed on return to immediate execution, can be used to capture any stack error information.
errcap=: 3 : 0 (3!:1 STACK_ERROR_INFO_base_) 1!:2 <":6!:0 '' 1!:2&2 'STACK_ERROR_INFO written to file' ) 9!:27 'i.0 [ errcap 0' NB. set latent expression 3 foo 'boo boo' [ 9!:29 ]1 NB. enable latent expression STACK_ERROR_INFO written to file