![]() |
Macintosh Development |
[Home]
[About Us]
[People]
[Information Systems]
[Kerberos for Macintosh]
[Applications]
[Miscellaneous Documentation]
![]() |
ErrorLib API Functions |
OSStatusGetMITLibError (void );voidSetMITLibError (OSStatus theError );voidClearMITLibError (void );
GetMITLibError()gets the current Kerberos Support Library error code. Clients should call this after calling MIT Support Library functions to check what error occurred. Some Kerberos Support Library functions do not set the error unless they report failure (for instance, you only need to callGetMITLibError()ifsocket()returns-1.
SetMITLibError()sets the current Kerberos Support Library error code. Only libraries needing to return errors back to client applications should call this function.
ClearMITLibError()sets the current Kerberos Support Library error code back tonoErr. Libraries using ErrorLib to return errors to callers should call this at the beginning of every API function.
OSStatusRegisterErrorTable (const FSSpec* inResFile,
SInt16 inResID );OSStatusRegisterErrorTableForBundle (CFStringRef inBundleID,
SInt16 inResID );
RegisterErrorTable()(Mac OS 8 and 9) andRegisterErrorTableForBundle()(Mac OS X) add new error to description string mappings to ErrorLib's error tables. When callingRegisterErrorTable(),inResFileis the resource file to get the error tables from. When callingRegisterErrorTableForBundle(),inBundleIDis the bundle identifier for the framework whose resource fork contains the error tables (usually the caller's bundle identifier).inResIDis the resource ID of the error table resource.Error tables are of resource type
'ErrT'. The resource template is defined in ErrorList.r. The short string is the name of the error (eg:ENOMEM) and the long string is a description of the error (eg: "Out of memory").The ErrorLib implementations of
RegisterErrorTable()andRegisterErrorTableForBundle()only saveinResFileandinResIDorinBundleID. The error tables will not actually get loaded until one of the error string functions described below is called. This is because if ErrorLib loaded all the Str255 error strings all the time, Kerberos Support Library would have a massive memory footprint and could not be called by code resources or applications short on memory. However, ErrorLib does keep the error strings for Resource Manager and Memory Manager errors loaded so that if the error table loading code fails it can generate an appropriate "Out of memory" error.
OSStatusGetErrorString (OSStatus error,
char *message,
long messageLength,
ErrorFormat format );OSStatusGetErrorLongFormat (OSStatus error,
char *message,
long messageLength );OSStatusGetErrorShortFormat (OSStatus error,
char *message,
long messageLength );OSStatusGetErrorManager (OSStatus error,
char *message,
long messageLength );OSStatusGetErrorLongString (OSStatus error,
char *message,
long messageLength );OSStatusGetErrorShortString (OSStatus error,
char *message,
long messageLength );
GetErrorString()loads the error string for the error specified byerrorand places the string inmessage.messageLengthis the size of the buffer allocated formessage(GetErrorString()will not overrun the buffer).formatis the format type you want the error string to be in. Possible values forformatare:
kErrorLongFormat:Returns a string of the form
"[Manager Name] returned [Short String] ([Error Code]: [Long string]."
(eg:"Open Transport returned kOTNoDataErr (-3162): No data available for reading.")kErrorShortFormat:Returns a string of the form
"[Manager Name]: [Short String] ([Error Code])"
(eg:"Open Transport: kOTNoDataErr (-3162)")kErrorManager:Returns the Manager Name kErrorLongString:Returns the Short String for the error. kErrorShortString:Returns the Long String for the error.
GetErrorLongFormat()is equivalent toGetErrorString()called withkErrorLongFormatas the format.
GetErrorShortFormat()is equivalent toGetErrorString()called withkErrorShortFormatas the format.
GetErrorManager()is equivalent toGetErrorString()called withkErrorManageras the format.
GetErrorLongString()is equivalent toGetErrorString()called withkErrorLongStringas the format.
GetErrorShortString()is equivalent toGetErrorString()called withkErrorShortStringas the format.
Questions or comments? Send mail to macdev@mit.edu
Last updated on $Date: 2003/11/19 20:49:33 $
Last modified by $Author: smcguire $