InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IErrorStringService Class Referenceabstract

#include <IErrorStringService.h>

Inheritance diagram for IErrorStringService:
IPMUnknownCPMUnknown< IErrorStringService >CErrorStringServiceBPIErrorStringServiceBscShpErrorStringServiceBscTAErrorStringServiceCdlChartErrorStringServiceCHLErrorStringServiceDataUpdaterErrorStringServiceFrmLblErrorStringServicePnlTrvErrorStringServicePstLstErrorStringServiceSnapErrorStringServiceSnipRunErrorStringServiceTranFxErrorStringServiceXCatHndErrorStringServiceXDocBkErrorStringService

Public Types

enum  { kDefaultIID = IID_IERRORSTRINGSERVICE }
 

Public Member Functions

virtual bool16 HasUserErrorString (ErrorCode errCode, IPMUnknown *errInfo) const =0
 
virtual PMString GetUserErrorString (ErrorCode errCode, IPMUnknown *errInfo) const =0
 
- Public Member Functions inherited from IPMUnknown
virtual IPMUnknownQueryInterface (PMIID interfaceID) const =0
 
virtual void AddRef () const =0
 
virtual void Release () const =0
 

Detailed Description

Interface which translates error codes based on the developer prefix of a plugin

into error strings (and for later versions a detailed error description).



This class is the hook for any plug-in that wishes to have a resource-based mapping

between error codes and error strings.



Here's how you would set up the mapping. First, define a boss in your plug-in that

provides an error string service, for instance:



<pre>

Class { kFooErrorStringServiceBoss, kInvalidClass, { IID_IK2SERVICEPROVIDER, kErrorStringProviderImpl, IID_IERRORSTRINGSERVICE, kFooErrorStringServiceImpl, } }

Then you need to provide an implementation of the error string service interface. Here's an example of what that might look like:


#include "CErrorStringService.h"
class FooErrorStringService : public CErrorStringService

{

public:

    FooErrorStringService(IPMUnknown * boss) :

    : CErrorStringService(boss, kFooPluginID, kFooErrorStringTableRsrcID)

};
    

Then you need to define the error codes that you want to map to error strings in your ID.h file. For instance:


Lastly, you need to have a UserErrorTable resource that provides the

mapping between an error code and its associated string:



<pre>

resource UserErrorTable( kFooErrorStringTableRsrcID ) { { err // error string kFooAwfulHorribleError, "Oh No! Something awful has happened!", kFooEvenWorseError, "Oh Dear! Please don't do that", } };

Note that the string provided in the UserErrorTable is not localized. To localize it, you can provide a localization in the localized string files, then it will be automatically translated for the current language.

Once you've done all this, then when you set the error code (see ErrorUtils::PMSetGlobalErrorCode), you can skip passing a string along, but when you (or anyone else) later request the string, it will be there. The advantage to this is if you set the error code the same way in multiple places, you insure that the error string will be the same no matter where it gets set from.

See Also
IK2ServiceProvider, CErrorStringService, ErrorUtils

Member Function Documentation

virtual PMString IErrorStringService::GetUserErrorString (ErrorCode errCode,
IPMUnknownerrInfo 
) const
pure virtual

Return the string associated with the error code. If there isn't one return an empty string.

Parameters
errCodethe error code we're looking up
errInfowhatever errInfo is currently in the error state
Returns
PMString the user string for errCode, kFalse otherwise

Implemented in CErrorStringService.

virtual bool16 IErrorStringService::HasUserErrorString (ErrorCode errCode,
IPMUnknownerrInfo 
) const
pure virtual

See if the service provider has a string for errCode. When searching for an error string, the application may iterate over all the services asking for a string. A quick check to see if it is even your prefix is advised. It could be that it is your error, yet you don't have a string for it, then return kFalse.

Parameters
errCodethe error code we're looking up
errInfowhatever errInfo is currently in the error state
Returns
kTrue if the service supplies a string for errCode, kFalse otherwise

Implemented in CErrorStringService.