Important: The information in this document is obsolete and should not be used for new development.
SysError
You can use theSysErrorprocedure to simulate a system error. Ordinarily, however, only the Operating System invokes this procedure.
PROCEDURE SysError (errorCode: Integer);
errorCode- The system error ID corresponding to the system error condition identified.
DESCRIPTION
TheSysErrorprocedure generates a system error with the system error ID specified by theerrorCodeparameter. The value of the system error ID determines the exact response of the System Error Handler (for example, whether it can intercept the error) and determines the contents of the system error alert box displayed for the error.The
SysErrorprocedure begins by saving all registers and the stack pointer and by storing the system error ID in a global variable (namedDSErrCode). The Finder uses this global variable when reporting that an application unexpectedly quit.If there is not a system error alert table in memory,
SysErrorloads it in. (The global variableDSAlertTabstores a pointer to the current system error alert table. If no system error alert table is in memory,DSAlertTabisNIL.) If there is no table in memory (indicating that the error likely occurred at the beginning of system startup), the System Error Handler draws the "sad Macintosh" icon and plays appropriate ominous tones through the Macintosh speaker. Different tones correspond to different problems that theSysErrorprocedure determines have occurred.After allocating memory for QuickDraw global variables on the stack and initializing QuickDraw,
SysErrorinitializes a graphics port in which the alert box is drawn. TheSysErrorprocedure draws the alert box (in the rectangle specified by the global variableDSAlertRect) unless theerrorCodeparameter contains a negative value. Note that the system error alert box is not a Dialog Manager modal dialog box. Negative values are used to force theSysErrorprocedure to display a sequence of consecutive messages in a system startup alert box without redrawing the entire alert box. If the value in theerrorCodeparameter does not correspond to an entry in the system error alert table, the default alert box definition at the start of the table is used, displaying the message "Sorry, a system error occurred."The
SysErrorprocedure uses the value in theerrorCodeparameter to determine the contents of the system error alert box. It looks in the system error alert table resource for an alert definition whose definition ID matches theerrorCodeparameter. It then draws the text and icon of the alert box according to that alert definition in the system error alert table.System error alert tables include procedures and button definitions. (See the description of the system error alert table resource in the section "The System Error Alert Table Resource" beginning on page 2-16, for details.) If the procedure definition ID in the table is not 0,
SysErrorinvokes the procedure with the specified ID. If the button definition ID in the table is 0,SysErrorreturns control to the procedure that called it. This mechanism allows the disk-switch alert box to return control to the File Manager after the "Please insert the disk:" message has been displayed.If a resume procedure has been defined, the button definition ID is incremented by 1. This mechanism allows the System Error Handler to use one of two layouts depending on whether a resume procedure has been defined. After drawing the buttons using QuickDraw rather than the Control Manager,
SysErrorperforms hit-testing on the buttons, highlighting them appropriately. When a button is pressed, the appropriate procedure is invoked. If there is no procedure code defined for a button, theSysErrorprocedure returns to the routine that called it. The resume procedure is described in the next section.SPECIAL CONSIDERATIONS
Calling theSysErrorprocedure might cause a system crash even if no condition that would have caused a system crash existed prior to the invocation ofSysError.
SysErrorworks correctly only if the following conditions are met:
- The trap dispatcher is operative. (See the chapter "Trap Manager" in this book for information about the trap dispatcher.)
- The Font Manager procedure
InitFontshas been called. Ordinarily, it is called when the system starts up.- Register A7 points to a reasonable place in memory (for example, not to video RAM).
- A few important system data structures do not appear to be too badly damaged.
SEE ALSO
A list of system error IDs is provided in Table 2-1 on page 2-7.