home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-09-28 | 1.9 KB | 57 lines | [TEXT/CWIE] |
- /*
- File: Error Macros.h
-
- Contains: These macros can be used to implement nice error handling within a function.
- Essentially, all errors jump to an error handler at the end of the function,
- which should cleanup any leftovers and return the appropriate error result.
-
- Note that the error handlers take a message string. This should be a good
- indication of the actual error, and it will appear when debugging is turned
- on.
-
- Note that any additional sanity checking code can be added to any function
- by using
-
- #if qDebugging
- // do additional sanity checking here.
- #endif
-
- For example, this could be used to check the internal validity of an object
- before taking an action.
-
- Written by: Timothy Carroll
-
- Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/2/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
- // App may want to override qDebugging
- #include "AppConditionals.h"
-
- #pragma once
-
- #ifndef qDebugging
- #define qDebugging 0
- #endif
-
- #if qDebugging
- #define SIGNAL_ERROR(msg) {DebugStr(msg); goto error;}
- #else
- #define SIGNAL_ERROR(msg) {goto error;}
- #endif
-
- #define FAIL_NIL(y,msg) if (y == NULL) SIGNAL_ERROR(msg)
- #define FAIL_OSERR(y,msg) if (y != noErr) SIGNAL_ERROR(msg)
- #define FAIL_FALSE(y,msg) if (!y) SIGNAL_ERROR(msg)
-