home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-08-10 | 1.2 KB | 40 lines | [TEXT/CWIE] |
- /*********************************************************************************
- ERROR HANDLING MACROS
- #
- 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.
-
- *********************************************************************************/
- // 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)
-