UIQ Technology
Symbian OS Library

UIQ 3.1 SDK        UIQ developer portal

[Index] [Spacer] [Previous] [Next]



How to use User::Leave()

You can use the User::Leave() function to terminate a functions processing immediately when an exception condition occurs. In the example below, if the new fails, the function calls User::Leave() with an error code. The return type of the function is void, because it is not necessary to use it to return error information.

void doExampleL()
 {
 CExample* myExample = new CExample;
 if (!myExample) User::Leave(KErrNoMemory);
 // leave used in place of return to indicate an error
 
 // do something
 myExample->iInt = 5;
 testConsole.Printf(_LIT("Value of iInt is %d.\n"),myExample->iInt);
 // delete
 delete myExample;
 }


Notes