HP Pascal/iX Programmer's Guide (31502-90023)
11- 5
The diagram below shows when, in time, the TRY-RECOVER statements labeled
A, B1, B2, and C in the preceding program are active. When more than one
TRY-RECOVER statement is active, the innermost one takes precedence.
The RECOVER's
statement
can use the predefined function escapecode to
determine the error that occurred and act accordingly.
Example 4
PROGRAM system;
IMPORT
system_escapecodes; {see note following example}
PROCEDURE support;
BEGIN
IF error THEN escape(88);
END;
PROCEDURE userprogram;
BEGIN
support;
END;
BEGIN {system}
TRY userprogram
RECOVER
CASE escapecode OF
minuser..maxuser : writeln('Software detected errors');
range : writeln('Value range error');
stackoverflow : writeln('Stack overflow');
ioverflow : writeln('Integer overflow');
idivbyzero : writeln('Integer divide by zero');
roverflow : writeln('Real overflow');
runderflow : writeln('Real underflow');
rdivbyzero : writeln('Real divide by zero');
nilpointer : writeln('Nil pointer reference');
casebounds : writeln('Case expression bounds error');
stroverflow : writeln('String overflow');
filerror : writeln('File I/O error');
OTHERWISE
writeln('Unrecognized error');
END; {CASE}
END. {system}
NOTE This is only an example. The operating system on which HP Pascal
runs does not use the constants that represent error codes in the
example above (
ioverflow, roverflow,
and so on).
A program can access error_code only by calling the predefined function
escapecode.