21 April 2005

Using of CErrorUI

Every application need to display errors such as "Out of memory". In this case you need a tool to display it from any point in your code without expencing coding. Symbian has class CErrorUI for it. Here some docs from SDL.

"CErrorUI provides a mechanism for applications to display a standard error message dialog to the user. Typically, this could be used to warn a user about Out Of Memory (OOM) conditions.
CErrorUI displays an error of the form:

context : error text

in a dialog box. The context of the error is usually the application or the subsystem where the error occurred. CErrorUI uses an instance of CTextResolver to derive the error text and error context from the error code. The context may be automatically selected (default) or may be set by the caller from a limited range.

When using automatic context (ECtxAutomatic) be aware the wrong context may be shown. If CTextResolver cannot decide the context from the error code, it may display a blank context or as the previous context that was displayed. The actual context text that is displayed depends on the SDK version used to build the application. For example; the error text for KErrCancel may display as 'System : System Error' or 'General : System Error'.

Utility class to display error notes by applications. This is the default error display class to be used by applications. The features of the class are: maps given error to error text to be displayed displays error note using timed, global note does not display error if it is already "on" offers a reference to internal TextResolver instance Usage (typically as instance variable)
iErrorUI = CErrorUI::NewL(); // iCoeEnv can be given as argument, no need to that though

// ... some code causing an error ...

if ( err != KErrNone )
iErrorUI->ShowGlobalErrorNoteL(err); "

Note that you need link your app to commonui.lib to use CErrorUI.

1 comment:

onchua2006 said...

How can I link file .lib in carbide.C++? Thanks for your help!