HP 3000 Manuals

An Example of Error Management [ Getting System Information Programmer's Guide ] MPE/iX 5.0 Documentation


Getting System Information Programmer's Guide

An Example of Error Management 

When an intrinsic returns an error, the error has usually been through a
number of translations.  For example, FINDJCW  calls a symbol table
routine that calls a table management routine that calls a virtual space
management routine.  If virtual space management returns an error to
table management, table management translates that error into a table
management error and returns it to symbol table management.  Symbol table
management then translates the table management error into a symbol table
management error and returns it to FINDJCW; FINDJCW translates the error
into a FINDJCW error and returns it to you.  The lower-level errors are
pushed onto the process error stack.  However, they are accessible
through the error management intrinsics described in this chapter.

To see the virtual space management error, call HPERRDEPTH to get the
depth of the error stack and then call HPERRREAD in a loop, passing in a
different depth each time (1...depth returned by HPERRDEPTH). After each
status is returned by HPERRREAD, check the subsystem part of the status
to see if it is the virtual space management subsystem.  When HPERRREAD
returns the status that you are looking for, call HPERRMSG, passing in
the status; and HPERRMSG returns or displays the error message that
corresponds to the status passed.  Example 9-1 demonstrates how to
complete this procedure.
____________________________________________________________________________
|                                                                          |
|                                                                          |
|      Item Subject: celep - test program for error handling               |
|      program test1(output);                                              |
|      const subsys_vs_man = 107;                                          |
|      type hpe_status = record case integer of                            |
|                        0 : (all :integer);                               |
|                        1 : (info : shortint;                             |
|                             subsys : shortint);                          |
|                        end;                                              |
|      var                                                                 |
|            jcwname      : packed array [1..255] of char;                 |
|            p            : ^char;                                         |
|            jcwvalue     : bit16;                                         |
|            status       : shortint;                                      |
|            depth,                                                        |
|            depth_count  : integer;                                       |
|            error_no     : hpe_status;                                    |
|      procedure findjcw; intrinsic;                                       |
|      procedure hperrread; intrinsic;                                     |
|      procedure hperrmsg; intrinsic;                                      |
|      procedure hperrdepth; intrinsic;                                    |
|                                                                          |
|      begin {program test1}                                               |
|        jcwname := 'TEST1$';                                              |
|        findjcw(jcwname,jcwvalue,status);                                 |
|        if status                                                         |
|      0 then      { status = 3, if not found }                            |
|          writeln('findjcw status=',status:1);                            |
|        p:=nil;                                                           |
|        findjcw(p^,jcwvalue,status);                                      |
|        if status                                                         |
|      0 then      { status = 2, if bad address }                          |
|          begin {findjcw failed}                                          |
|          hperrdepth(depth);                                              |
|          depth_count := 1;                                               |
|          while depth_count <= depth do                                   |
|            begin {while loop}                                            |
|            hperrread(depth_count,error_no);                              |
|            if error_no.subsys = subsys_vs_man then                       |
|              begin                                                       |
|              hperrmsg(5,,,error_no);                                     |
|              depth_count:=depth;                                         |
|              end;                                                        |
|            depth_count := depth_count + 1;                               |
|            end; {while loop}                                             |
|          { this writeln may not appear above or error stack is cleared } |
|          writeln('findjcw status=',status:1,' depth=',depth:1);          |
|          end; {findjcw failed}                                           |
|      end. {program test1}                                                |
|                                                                          |
____________________________________________________________________________

          Example 9-1.  Obtaining a Virtual Space Management Error 



MPE/iX 5.0 Documentation