×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Using CTextResolver to resolve error texts

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Move into archived namespace)
lpvalente (Talk | contribs)
m (Lpvalente -)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Archived|timestamp=20120313125951|user=roy.debjit| }}
 
 
[[Category:Symbian C++]][[Category:Code Snippet]][[Category:Files/Data]][[Category:S60 3rd Edition FP1]][[Category:Code Snippet]]
 
[[Category:Symbian C++]][[Category:Code Snippet]][[Category:Files/Data]][[Category:S60 3rd Edition FP1]][[Category:Code Snippet]]
 +
{{Archived|timestamp=20120313125951|user=roy.debjit| }}
 +
 
{{ArticleMetaData <!-- v1.2 -->
 
{{ArticleMetaData <!-- v1.2 -->
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
Line 28: Line 29:
 
    
 
    
 
==Overview==
 
==Overview==
This code snippet shows how the class {{Icode|CTextResolver}} is used to resolve the corresponding error texts for error codes. The class {{Icode|CTextResolver}} has two versions of the method {{Icode|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.
+
{{Abstract|This code snippet shows how the class {{Icode|CTextResolver}} is used to resolve the corresponding error texts for error codes. The class {{Icode|CTextResolver}} has two versions of the method {{Icode|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 <nowiki>=</nowiki> ECtxAutomatic), the assumption is that the error codes are unique.}}
  
 
This snippet can be self-signed.
 
This snippet can be self-signed.

Latest revision as of 00:10, 2 September 2012

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Tested with
Devices(s): Nokia N93
Compatibility
Platform(s): S60 3rd Edition, FP1
S60 3rd Edition FP1
Article
Keywords: CTextResolver, CTextResolver::NewL(), CTextResolver::ResolveErrorString()
Created: aknyman (13 May 2008)
Last edited: lpvalente (02 Sep 2012)

Contents

[edit] 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.

[edit] MMP file

The following libraries are required:

LIBRARY commonui.lib


[edit] 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__

[edit] 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 );
}


[edit] Postconditions

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

[edit] See also

Archived:Using class CErrorUI to display error notes

This page was last modified on 2 September 2012, at 00:10.
116 page views in the last 30 days.
×