Symbian
Symbian OS Library

FAQ-0810 How can I handle error codes more conveniently on Symbian OS v7.0?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Errors & Error Handling
Created: 08/16/2002 Modified: 08/26/2003
Number: FAQ-0810
Platform: Symbian OS v7.0

Question:
I am calling a method which I know can return error codes. I don't want the calling method to leave, but I would still like to be able to alert the end user to the possibility of problems. How can I do this when all I have is an integer error code, the value of which is only known at run time?

Answer:
Convenient handling of error codes can be performed under Symbian OS v7.0 by an extension of the existing API for handling the standard system-wide error codes (defined in e32std.h). The API now handles by default all the error codes that client code is likely to encounter on Symbian OS. The most important methods are:
    void CEikonEnv::GetErrorText(TDes& aDes,TInt aError) constand

      void CEikonEnv::ResolveError(TInt aError, TUid aAppUid)
      They are declared in eikenv.h. The first of these allows a (fairly) user-friendly string to be passed back via a descriptor provided by the API user for the purpose. The descriptor for safety should have length KErrorTextLength=80. The second method notifies the phone user directly of the problem by posting the resolved error text to an AlertWin. The UID is passed in to allow resolution of application-specific errors: normally KNullUid should be used. If for any reason your error code cannot be resolved, it will be treated as KErrUnknown. The similar method HandleError(...) is internal to Symbian and should not be used.