Guardian Programmer's Guide

Table Of Contents
Using the File System
Guardian Programmer’s Guide 421922-014
2 - 27
Handling File-System Errors
Error numbers in the range 10 and up indicate an error encountered in a standard
operation, such as an attempt to access a file before it is open, or that a system
component failed while the procedure was executing.
Error numbers 300 through 511 are reserved for application-dependent use.
Returned Error Numbers and Condition Codes
Some file-system procedures return the error number directly to the calling program.
Others return only a condition code as follows:
Following procedure calls that provide only a condition code, your program must issue
a FILE_GETINFO_ call to obtain the error number.
Your program should always check for errors immediately after executing a file-system
procedure call. If the call returns the error itself, simply check the return value. If a
nonzero error number is returned, your program could, for example, call a user-written
procedure to process the error. The following example calls the procedure
FILE^ERRORS to process the error number:
FILE^NAME ':=' "$OURVOL.MYSUBVOL.DATAFILE" -> @S^PTR;
LENGTH := @S^PTR '-' @FILE^NAME;
ERROR := FILE_OPEN_(FILE^NAME:LENGTH,
FILENUM);
IF ERROR <> 0 THEN CALL FILE^ERRORS(ERROR);
If the procedure sets a condition code, you need to call the FILE_GETINFO_
procedure to determine the error number. The error number is returned in the second
parameter:
CALL WRITEX(FILENUM,BUFFER,WCOUNT);
IF <> THEN
BEGIN
CALL FILE_GETINFO_(FILENUM,ERROR);
CALL FILE^ERRORS(ERROR);
END;
The Guardian Procedure Calls Reference Manual indicates which procedures return
the error number and which procedures set a condition code.
The procedure FILE^ERRORS might, for example, simply print the error number on
the terminal. The user would then be expected to look up the error number using the
ERROR command. The sample program at the end of this section shows a procedure
coded to work this way. Alternatively, FILE^ERRORS could be coded to communicate
directly with the ERROR program, causing the error text to be displayed on the
terminal screen without the need for manual intervention. Section 20, Interfacing With
the ERROR Program, describes how to do this.
> condition-code-greater-than (CCG) indicates a warning
< condition-code-less-than (CCL) indicates an error
= condition-code-equal (CCE) indicates successful execution