×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Using CTextResolver to resolve error texts

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
lpvalente (Talk | contribs)
m (Lpvalente -)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Symbian C++]][[Category:Code Examples]][[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]]
__NOTOC__
+
{{Archived|timestamp=20120313125951|user=roy.debjit| }}
__NOEDITSECTION__
+
{{KBCS}}
+
{{ArticleMetaData
+
|id=CS000966
+
|platform=S60 3rd Edition, FP1
+
|devices=Nokia N93
+
|category=Symbian C++
+
|subcategory=Files/Data
+
|creationdate=May 20, 2008
+
|keywords=CTextResolver, CTextResolver::NewL(), CTextResolver::ResolveErrorString()
+
  
 +
{{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]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
+
|devices= Nokia N93
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|platform= S60 3rd Edition, FP1
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. -->)
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|author=[[User:Aknyman]]
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= CTextResolver, CTextResolver::NewL(), CTextResolver::ResolveErrorString()
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20080513
 +
|author= [[User:Aknyman]]
 +
<!-- The following are not in current metadata -->
 +
|subcategory= Files/Data
 +
|id= CS000966
 
}}
 
}}
{{Archived|timestamp=20120313125951|user=roy.debjit| }}
 
 
    
 
    
 
==Overview==
 
==Overview==
This code snippet shows how the class <tt>CTextResolver</tt> is used to resolve the corresponding error texts for error codes. The class <tt>CTextResolver</tt> has two versions of the method <tt>ResolveErrorString()</tt>: 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.
Line 32: Line 38:
  
 
<code>
 
<code>
LIBRARY commonui.lib
+
LIBRARY commonui.lib
 
</code>
 
</code>
  
Line 161: Line 167:
 
==Postconditions==
 
==Postconditions==
  
The class <tt>CTextResolver</tt> resolves the error text when the method called by the user leaves.
+
The class {{Icode|CTextResolver}} resolves the error text when the method called by the user leaves.
  
 
==See also==
 
==See also==
[[CS000965 - Using class CErrorUI to display error notes]]
+
[[Archived:Using class CErrorUI to display error notes]]

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.
106 page views in the last 30 days.
×