Next Page > Hide TOC

Error Handler Reference

Framework
CoreServices/CoreServices.h
Declared in
IOMacOSTypes.h
MacErrors.h
OSTypes.h

Overview

In Mac OS 9, Error Handler provides a system service that displays system alerts seen during startup, and assumes control when certain low-level errors occur. For detailed information, see the chapter “System Error Handler” in Inside Macintosh: Operating System Utilities. A PDF version of this chapter is available at http://developer.apple.com/documentation/mac/pdf/Operating_System_Utilities/pdf.html.

Note: In Mac OS X, Error Handler is no longer used for this purpose—for more information, see SysError.

The header MacErrors.h defines result codes that are used by many Carbon functions to indicate their return status. Developers can also define custom result codes for their own applications, using the range 1000 through 9999 inclusive (Apple reserves all values outside of this range for internal use.) For more information, see Technical Q&A OV02 at http://developer.apple.com/qa/ov/ov02.html.

Functions

SysError

In Mac OS 9, displays a low-level system alert or dialog. The appearance and semantics of the alert or dialog can vary, depending on the error code passed in.

Not recommended

void SysError (
   short errorCode
);

Parameters
errorCode

A value or code that indicates a specific condition.

Discussion

A Carbon application running in Mac OS 9 can use this function to simulate a low-level system error. To exit in a more graceful manner when a serious error occurs, your application should call ExitToShell instead.

In Mac OS X, this function:

  1. Prints a message containing the value of errorCode in the console log. Does not display a system alert or dialog.

  2. If the variable USERBREAK is defined in the process environment, raises a SIGINT signal. Otherwise, returns control to the caller.

If a signal is raised and the caller does not handle the signal, the calling process is automatically terminated.

Availability
Declared In
MacErrors.h

Data Types

OSErr

A numeric code used in Carbon to indicate the return status of a function.

typedef SInt16 OSErr;

Discussion

The system software sometimes uses error codes to inform an application that a requested service is not possible. Many functions return a result code of type OSErr that indicates whether the function completed successfully, and if not, what the reason for failure was.

Availability
Declared In
IOMacOSTypes.h

OSStatus

A numeric code used in Carbon to indicate the return status of a function.

typedef SInt32 OSStatus;

Discussion

The system software sometimes uses error codes to inform an application that a requested service is not possible. Many functions return a result code of type OSStatus that indicates whether the function completed successfully, and if not, what the reason for failure was.

If you want to use OSStatus to define error codes for your application, Apple recommends that you use values in the range 1000 through 9999 inclusive. Values outside of this range are reserved by Apple for internal use.

Availability
Declared In
OSTypes.h

Next Page > Hide TOC


© 2003 Apple Computer, Inc. All Rights Reserved. (Last updated: 2003-01-01)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.