Determines the action taken when an error is detected inside a user-written procedure or function.
The following is a listing of the procedures used in this example:
PRO PROC1 FOR i = 1, 4 DO BEGIN
PROC2, i
ENDFOR END PRO PROC2, j ON_ERROR, 0
IF (j MOD 2) EQ 0 THEN BEGIN
PROC3, j
ENDIF ELSE BEGIN
PROC4, j
ENDELSE END PRO PROC3, k PAINT, k, ' is even.'
END PRO PROC4, m PRINT, m, ' is odd.' END
errex.pro
in your working directory, all of them can be compiled with the following command:
.RUN errex
PROC1 1 is odd. % Attempt to call undefined % procedure/function: PAINT. % Execution halted at PROC3 errex.pro(21). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$.
INFO, /Traceback % At PROC3 errex.pro(22). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$.
ON_ERROR, 0
ON_ERROR, 1
RETALL .RUN errex
To execute PROC1 again and check where PV-WAVE returns after the error in PROC3, issue the following command:
PROC1 1 is odd. % Attempt to call undefined % procedure/function: PAINT. % Execution halted at PROC3 errex.pro(21). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$. INFO, /Traceback % At $MAIN$.
ON_ERROR, 1
ON_ERROR, 3
RETALL .RUN errex
PROC1 1 is odd. % Attempt to call undefined % procedure/function: PAINT. % Execution halted at PROC3 errex.pro(21). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$.
INFO, /Traceback % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$.
ON_ERROR, 3
ON_ERROR, 0, /Continue
RETALL .RUN errex
PROC1 1 is odd. % Attempt to call undefined % procedure/function: PAINT. % Error occurred at PROC3 errex.pro(21). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$. 3 is odd. % Attempt to call undefined % procedure/function: PAINT. % Error occurred at PROC3 errex.pro(21). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$.
INFO, /Traceback % At $MAIN$.
ON_ERROR, 0, /Continue
ON_ERROR, 1, /Continue
RETALL .RUN errex
PROC1 1 is odd. % Attempt to call undefined % procedure/function: PAINT. % Error occurred at PROC3 errex.pro(21). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$.
INFO, /Traceback % At $MAIN$.
ON_ERROR, 1, /Continue
ON_ERROR, 2, /Continue
RETALL .RUN errex
PROC1 1 is odd. % Attempt to call undefined % procedure/function: PAINT. % Error occurred at PROC3 errex.pro(21). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$. 3 is odd.
INFO, /Traceback % Called from $MAIN$.
NOTE: In this example, execution continued in PROC3 after the error, and PROC1 finished executing.
PRO PROC1 FOR i = 1, 4 DO BEGIN
PROC2, i
ENDFOR END PRO PROC2, j ON_ERROR, 0
IF (j MOD 2) EQ 0 THEN BEGIN
PROC3, j
ENDIF ELSE BEGIN
PROC4, j
ENDELSE END PRO PROC3, k PAINT, k, ' is even.'
END PRO PROC4, m PRINT, m, ' is odd.' END
errex.pro
in your working directory, all of them can be compiled with the following command:
.RUN errex
PROC1 1 is odd. % Attempt to call undefined % procedure/function: PAINT. % Execution halted at PROC3 errex.pro(21). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$.
INFO, /Traceback % At PROC3 errex.pro(22). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$.
If the call to ON_ERROR in PROC2 is changed from
ON_ERROR, 0
ON_ERROR, 1
RETALL .RUN errex
To execute PROC1 again and check where PV-WAVE returns after the error in PROC3, issue the following command:
PROC1 1 is odd. % Attempt to call undefined % procedure/function: PAINT. % Execution halted at PROC3 errex.pro(21). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$. INFO, /Traceback % Called from $MAIN$.
As a final example, the call to ON_ERROR in PROC2 is changed from
ON_ERROR, 1
ON_ERROR, 3
RETALL .RUN errex
PROC1 1 is odd. % Attempt to call undefined % procedure/function: PAINT. % Execution halted at PROC3 errex.pro(21). % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$.
INFO, /Traceback % Called from PROC2 errex.pro(13). % Called from PROC1 errex.pro(5). % Called from $MAIN$.
For more information, see Error Handling in Procedures in Chapter 9 of the PV-WAVE Programmer's Guide.
Additional information can be found in Description of Error Handling Routines in Chapter 10 of the PV-WAVE Programmer's Guide.