Archived:Using CTextResolver to resolve error texts
m (Protected "CS000966 - Using class CTextResolver to resolve error texts" [edit=sysop:move=sysop]) |
|||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
__NOEDITSECTION__ | __NOEDITSECTION__ | ||
| − | + | {{KBCS}} | |
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0" | {|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0" | ||
|- | |- | ||
| − | |'''ID''' || | + | |'''ID''' || CS000966 |
| − | |'''Creation date''' || May | + | |'''Creation date''' || May 20, 2008 |
|- | |- | ||
|'''Platform''' || S60 3rd Edition, FP1 | |'''Platform''' || S60 3rd Edition, FP1 | ||
| Line 21: | Line 21: | ||
==Overview== | ==Overview== | ||
| − | This code snippet shows how the class <tt>CTextResolver</tt> is used to resolve corresponding error texts for error codes. The class <tt>CTextResolver</tt> has two versions of method <tt>ResolveErrorString()</tt> | + | 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. |
This snippet can be self-signed. | This snippet can be self-signed. | ||
| Line 162: | Line 162: | ||
==See also== | ==See also== | ||
| − | [[ | + | [[CS000965 - Using class CErrorUI to display error notes]] |
| − | [[Category:Symbian C++]][[Category:Code Examples]][[Category:Files/Data]] | + | [[Category:Symbian C++]][[Category:Code Examples]][[Category:Files/Data]] [[Category:S60 3rd Edition, Feature Pack 1]] |
Revision as of 12:55, 20 May 2008
| 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.

