Symbian
Symbian OS Library

FAQ-0798 How can I handle error codes more conveniently on Symbian OS v6.x?

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



 

Classification: C++ Category: Errors & Error Handling
Created: 06/07/2002 Modified: 12/12/2002
Number: FAQ-0798
Platform: Symbian OS v6.0, Symbian OS v6.1

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:
In the Nokia 9200 Communicator series SDK for Symbian OS v6.0 there is a CErrResolver class you can use to get a human readable string in exchange for an integer error code. The following code can be used to display the text in an info dialog on a 9200 series communicator:

#include // For CCknInfoDialog
#include // For CErrResolver

void CMyAppUi::HandleErrorMessageL(const TInt aMessage)
    {
    _LIT(KDialogTitle, "Information"); // read this string from a resource file in production code
    // Get error message text from resolver.
    CErrResolver* errResolver = CErrResolver::NewLC(*iEikonEnv);
    TPtrC message = errResolver->ResolveError(aMessage);
    if (message.Length()) // Empty messages are not shown.
      {
      // Display error message.
      CCknInfoDialog::RunDlgLD(KDialogTitle, message, NULL);
      }CleanupStack::PopAndDestroy(); // errResolver
      }
      This API was modified for the Nokia Series 60 SDK for Symbian OS v6.1. The functionality equivalent to CErrResolver is provided by a class CTextResolver defined in TextResolver.h. An additional class CErrorUI defined in ErrorUI.h provides a convenient API to do the additional work of putting up an info dialog using CTextResolver to resolve an error code to a string which it then displays. The typical usage of these two classes is explained in the header files in which they are defined.

      For more details see the technical paper "Error Resolution on Symbian OS v6.x" on http://www.symbian.com/developer/techlib/papers/errores/Erresapi.html.