Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 09:55, 20 May 2008.

CS000966 - Using class CTextResolver to resolve error texts

From Forum Nokia Wiki


ID CS000966 Creation date May 20, 2008
Platform S60 3rd Edition, FP1 Tested on devices Nokia N93
Category Symbian C++ Subcategory Files/Data


Keywords (APIs, classes, methods, functions): CTextResolver, CTextResolver::NewL(), CTextResolver::ResolveErrorString()

Overview

This code snippet shows how the class CTextResolver is used to resolve the corresponding error texts for error codes. The class CTextResolver has two versions of the method ResolveErrorString(): the first one is for normal use and the second one is for advanced use. Both versions of the method are used in this example. It is also possible to give an optional error context to map error codes to texts in a unique way. If no context is given (aContext = ECtxAutomatic), the assumption is that the error codes are unique.

This snippet can be self-signed.

MMP file

The following libraries are required:

LIBRARY  commonui.lib


Header file

#ifndef __TESTERAPPUI_H__
#define __TESTERAPPUI_H__
 
// INCLUDES
#include <aknappui.h>
 
// FORWARD DECLARATIONS
class CTextResolver;
 
 
class CTesterAppView : public CCoeControl
    {
private:
  // Functions from base classes
  void HandleCommandL(TInt aCommand);
//...  
  void DoHandleCommandL(TInt aCommand);    
 //... 
private:    
    CTextResolver* iTextResolver;
    };
 
#endif // __TESTERAPPUI_H__

Source file

#include <textresolver.h>
 
void CTesterAppUi::ConstructL()
  {
  //...  
   iTextResolver = CTextResolver::NewL(*iCoeEnv);  
  }
  
CTesterAppUi::~CTesterAppUi()
  {
  //...
  delete iTextResolver;
  }
  
void CTesterAppUi::HandleCommandL(TInt aCommand)
  {  
    switch (aCommand)
      {
      case EEikCmdExit:
      case EAknSoftkeyExit:
        Exit();
        break;
        
      case ECommand1:
        {  
        TPtrC errorTextPtr; // pointer to returned error text
        
        TRAPD( errSimple, DoHandleCommandL( aCommand ) );
        if ( errSimple != KErrNone )
          {
          // resolve the given error code 
          errorTextPtr.Set(iTextResolver->ResolveErrorString(errSimple)); 
          }
        else
          {
          // KErrNone, do something....
          } 
        }
        break;
    
      case ECommand2:
        {  
        TInt textId =0;     // ID of the returned text
        TUint flags = 0;    // priority of the returned error 
        TPtrC errorTextPtr; // pointer to returned error text 
        
        TRAPD( errAdvanced, DoHandleCommandL( aCommand ) );
        if ( errAdvanced != KErrNone)
          {
          // resolve the given error code
          errorTextPtr.Set(iTextResolver->ResolveErrorString(errAdvanced, textId, flags)); 
          
            //the flag indicates that the error has no proper explanation
          if (flags & EErrorResBlankErrorFlag)
            {
            // do something...
            }
          
          //the flag indicates that Text Resolver does not support the error code
          if (flags & EErrorResUnknownErrorFlag)
            {
            // do something...
            }
                
          //the flag is returned while processing KErrNoMemory error code
          if (flags & EErrorResOOMFlag)
            {
            // do something...
            }
          }
        else
          {
          // KErrNone do something...
          }
        }
        break;
 
    default:
      Panic(ETesterUi);
      break;
    }
  }
 
void CTesterAppUi::DoHandleCommandL(TInt aCommand)
  {
  //Do Something that might leave...
  User::Leave(KErrNotSupported );    
  }


Postconditions

The class CTextResolver resolves the error text when the method called by the user leaves.

See also

CS000965 - Using class CErrorUI to display error notes

Related Discussions
Thread Thread Starter Forum Replies Last Post
[moved] nmake error msgurikar Symbian Tools & SDKs 20 2008-08-06 12:33
Tab ordering on Forms alonish Mobile Java General 1 2007-01-31 05:28
Does Real player in Nokia 6630 support rm streaming in TCP ? leepatricklee Graphics & Video & Streaming 5 2007-05-05 11:31
Play Audio file problem Aliencse Symbian Media (Graphics & Sounds) 21 2008-09-16 14:12
SIP 403 Forbidden error amit.v.pendse VoIP 3 2008-06-20 08:09
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX