InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ErrorUtils Class Reference

#include <ErrorUtils.h>

Static Public Member Functions

static void PMSetGlobalErrorCode (ErrorCode errCode, const PMString *errString=nil, IPMUnknown *errInfo=nil, const PMString *contextInfo=nil)
 
static ErrorCode PMGetGlobalErrorCode ()
 
static PMString PMGetGlobalErrorString ()
 
static IPMUnknownPMQueryGlobalErrorInfo ()
 
static PMString PMGetGlobalContextInfo ()
 
static PMString PMGetErrorString (ErrorCode errCode, IPMUnknown *errInfo=nil)
 
static PMString PMLoadErrorStringFromRsrc (ErrorCode errCode, PluginID errorRsrcPluginId, RsrcID errorTableId)
 
static void SetExitCode (int16 exitCode)
 
static int16 GetExitCode ()
 

Detailed Description

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

Member Function Documentation

static int16 ErrorUtils::GetExitCode ()
static

Get the application's exit code. For internal use only.

static PMString ErrorUtils::PMGetErrorString (ErrorCode errCode,
IPMUnknownerrInfo = nil 
)
static

Finds the error string corresponding to the errCode Queries all services for user errors and redirects to application for platform errors

Parameters
errCodethe error code to search for
isPlatform(pass false)
errInfoother info necessary for resolving the error string
Returns
PMString the default error string to use for this error
static PMString ErrorUtils::PMGetGlobalContextInfo ()
static

May be empty, but if full contains context information about where the error occurred. This will contain whatever stack information can be determined on Macintosh Debug, otherwise it will empty.

static ErrorCode ErrorUtils::PMGetGlobalErrorCode ()
static

Gets the current global error code

Returns
the current error code, or kSuccess if there's no error
static PMString ErrorUtils::PMGetGlobalErrorString ()
static

Gets the current global error string. The string may be empty.

Returns
PMString the error string
static PMString ErrorUtils::PMLoadErrorStringFromRsrc (ErrorCode errCode,
PluginID errorRsrcPluginId,
RsrcID errorTableId 
)
static

Read the user error string from the current resource fork. This is a helper function provided because almost every user error string service will need the same functionality. This function is different from PMGetErrorString in that it only reads the error. If it isn't in the current resource fork it won't find it.

static IPMUnknown* ErrorUtils::PMQueryGlobalErrorInfo ()
static

Returns the current global error info

Returns
IPMUnknown* the optional extra information posted with the error state
static void ErrorUtils::PMSetGlobalErrorCode (ErrorCode errCode,
const PMStringerrString = nil,
IPMUnknownerrInfo = nil,
const PMStringcontextInfo = 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
errCodethe new error code
isPlatformis it a platform error code (should always be false)
errStringmessage string to show in the alert box
errInfoany extra information you want to attach to the error state
static void ErrorUtils::SetExitCode (int16 exitCode)
static

Set the application's exit code. For internal use only.