Archived:Using class CErrorUI to display error notes
Contents |
Overview
This code snippet shows how the class CErrorUi is used to display error notes ("context : error text"). The context of the error can be the application or the subsystem where the error has occurred. The caller can self-define the context or it is automatically selected. The class CErrorUi maps the given error to the error text to be displayed and contains a reference to the internal CTextResolver instance.
- ShowGlobalErrorNoteL() shows a global error note
- ShowGlobalErrorQueryL() shows a global error query with the OK key
- TextResolver() offers a reference to the internal TextResolver instance
Note:
In the target device the ErrRd file is required to enable error notes. The correct location for the ErrRd file is in the c:\resource directory. The Wiki page How can I get extended information in error messages on Symbian shows how to create a SIS file to install the ErrRd file.
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 CErrorUI;
class CTesterAppView : public CCoeControl
{
private:
// Functions from base classes
void HandleCommandL(TInt aCommand);
//...
void DoHandleCommandL(TInt aCommand);
//...
private:
CErrorUI* iErrorUi;
};
#endif // __TESTERAPPUI_H__
Source file
#include <errorui.h>
void CTesterAppUi::ConstructL()
{
//...
iErrorUi = CErrorUI::NewL();
}
CTesterAppUi::~CTesterAppUi()
{
//...
delete iErrorUi;
}
void CTesterAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
case ECommand1:
{
TRAPD( errNote, DoHandleCommandL( aCommand ) );
if ( errNote )
{
iErrorUi->ShowGlobalErrorNoteL( errNote );
TPtrC errorMessage( iErrorUi->TextResolver().ResolveErrorString( errNote ) );
// do something with the error message...
}
else
{
// KErrNone, do something....
}
}
break;
case ECommand2:
{
TRAPD( errQuery, DoHandleCommandL( aCommand ) );
if ( errQuery )
{
iErrorUi->ShowGlobalErrorQueryL( errQuery );
TPtrC errorMessage( iErrorUi->TextResolver().ResolveErrorString( errQuery ) );
// do something with the error message...
}
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 CErrorUi shows a global error note or a global error query when the method called by the user leaves.
See also
Archived:Using CTextResolver to resolve error texts
How can I get extended information in error messages on Symbian


(no comments yet)