Provides a code snippet to explain how to use User::Leave().
You can use the User::Leave() function to terminate a function’s 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; }