Symbian3/PDK/Source/GUID-8DF1C625-7963-55E9-BEEC-C9E37936F8CF.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 11 Mar 2010 18:02:22 +0000
changeset 3 46218c8b8afa
parent 1 25a17d01db0c
child 5 f345bda72bc4
permissions -rw-r--r--
week 10 bug fix submission (SF PDK version): Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-8DF1C625-7963-55E9-BEEC-C9E37936F8CF" xml:lang="en"><title>How
to use User::Leave()</title><shortdesc>Provides a code snippet to explain how to use <codeph>User::Leave()</codeph>.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>You can use the <codeph>User::Leave()</codeph> function to terminate a
function’s processing immediately when an exception condition occurs. In the
example below, if the <codeph>new</codeph> fails, the function calls <codeph>User::Leave()</codeph> with
an error code. The return type of the function is <codeph>void</codeph>, because
it is not necessary to use it to return error information.</p>
<codeblock id="GUID-98542124-DB23-5A8F-8387-F0781B32D1F2" xml:space="preserve">void doExampleL()
 { 
 CExample* myExample = new CExample;
 if (!myExample) User::Leave(KErrNoMemory); 
 // leave used in place of return to indicate an error
 
 // do something
 myExample-&gt;iInt = 5;
 testConsole.Printf(_LIT("Value of iInt is %d.\n"),myExample-&gt;iInt);
 // delete
 delete myExample;
 }</codeblock>
<section id="GUID-98FF9DEC-DC09-43DE-ABAD-3EE9C2597A85"><title>Notes</title> <ul>
<li id="GUID-7891ACB0-D39E-5982-BF3E-43DD01281F77"><p>the <codeph>L</codeph> suffix
on a function name indicates that it may leave</p> </li>
</ul> </section>
</conbody></concept>