Utilities for getting and setting the global error state. The global error state holds an error code, an error string (typically for showing in an alert box), and (optionally) an object to hold whatever additional information is necessary. The error string may be set at the time the error is set, or it may be dynamically assocated with the error by putting it in an UserErrorTable resource.
- See Also
- UserErrorTable
| static void ErrorUtils::PMSetGlobalErrorCode | ( | ErrorCode | errCode, | | | const PMString * | errString = nil, | | | IPMUnknown * | errInfo = nil, | | | const PMString * | contextInfo = nil | | ) | | |
| static |
Sets the global error code on the session. The error code starts off kSuccess. When it gets set to anything else, it goes into error state. Once it is in error state, subsequent attempts to set the error code are ignored, until the error code is restored to kSuccess. This is because sometimes one error can result in a cascade of other errors, but the important error to report is the original error.
If no string is passed (or string is nil), the central error handling code will attempt to find a string based on the error code. It maintains a registry of strings declared in UserErrorTable resources, and will return the first matching string it finds for any subsequent requests. For directions on how to use the facility, see IErrorStringService.h
- See Also
- IErrorStringService
errInfo can be an error specific object that contains more information about the error. The object only means something to the originator of the error and the handler of the error. For instance, suppose the error is "file %s not found", where you want s to be filled in with the filename. It could be that associated with the file not found error is an object containing the filename. PMSetGlobalErrorCode will do an AddRef on the errInfo, so that it may keep its own reference to the object.
- Parameters
| errCode | the new error code |
| isPlatform | is it a platform error code (should always be false) |
| errString | message string to show in the alert box |
| errInfo | any extra information you want to attach to the error state |