Important: The information in this document is obsolete and should not be used for new development.
ResError
After calling a Resource Manager routine, you can use theResError
function to determine whether an error occurred and, if so, what it was.
FUNCTION ResError: Integer;DESCRIPTION
TheResError
function reads the value stored in the system global variableResErr
and returns an integer result code identifying errors, if any, that occurred. If no error occurred,ResError
returnsnoErr
. If an error occurs at the Resource Manager level,ResError
returns one of the integer result codes listed in this section. If an error occurs at the Operating System level,ResError
returns an Operating System result code, such as the Memory Manager errormemFullErr
or the File Manager errorioErr
.Resource Manager procedures do not report error information directly. Instead, after calling a Resource Manager procedure, your application should call the
ResError
function to determine whether an error occurred.Resource Manager functions usually return
NIL
or -1 as the function result when there's an error. For Resource Manager functions that return -1, your application can call theResError
function to determine the specific error that occurred. For Resource Manager functions that return handles, your application should always check whether the value of the returned handle isNIL
. If it is, your application can useResError
to obtain specific information about the nature of the error. Note, however, that in some casesResError
returnsnoErr
even though the value of the returned handle isNIL
.
Only those result codes dealing specifically with resources are listed in this section. See the description of each Resource Manager routine for a list of errors specific to that routine and that the
- IMPORTANT
- In certain cases, the
ResError
function returnsnoErr
even though a Resource Manager routine was unable to perform the requested operation. See the individual routine descriptions for details about the circumstances under which this happens.ResError
function returns.ASSEMBLY-LANGUAGE INFORMATION
The global variableResErr
stores the current value ofResError
, that is, the result code of the most recently performed Resource Manager operation. In addition, you can specify an application-defined procedure to be called whenever an error occurs. To do this, store the address of the procedure in the global variableResErrProc
. The value of theResErrProc
global variable is usually 0. Before returning a result code other thannoErr
, theResError
function puts that result in register D0 and calls the procedure identified by theResErrProc
global variable.If you use
ResErrProc
to detect resource errors, you will get unexpected calls to your application-defined procedure if you callGetMenu
. The Menu Manager routineGetMenu
makes a call toGetResInfo
, requesting resource information about
'MDEF
' 0. Unfortunately, becauseROMMapInsert
is set toFALSE
, this call fails, settingResErr
to -192 (resNotFound
). This, in turn, causes a call to your application-defined procedure, even though theGetMenu
routine has worked correctly.To avoid this problem, follow these steps when you call
GetMenu
if you are usingResErrProc
:
- Save the address of your application-defined procedure.
- Clear
ResErrProc
.- Call
GetResource
for the menu resource you want to get.- Check whether
GetResource
returns a handle whose value isNIL
; if so, process the error in whatever way is appropriate for your application.- Call
GetMenu
.- When you are finished calling
GetMenu
, restore the previous value ofResErrProc
.
RESULT CODES