Symbian3/PDK/Source/GUID-40671EEC-DACC-5F0B-978C-2794FB206E62.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-40671EEC-DACC-5F0B-978C-2794FB206E62" xml:lang="en"><title>Types
       
    13 of error and recovery</title><shortdesc>Describes error conditions and how errors are handled.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>Error conditions can be divided into three broad categories:</p>
       
    15 <ul>
       
    16 <li id="GUID-5E06C730-C4DC-5E09-A7F1-8101BC8B6AFC"><p>program errors, such
       
    17 as an attempt to access an element beyond the bounds of an array or buffer</p> </li>
       
    18 <li id="GUID-DFCB0C57-A2BB-55DF-BA2A-FC0D5D3C9F45"><p>environment errors,
       
    19 such as insufficient memory, insufficient disk space, or other missing resources</p> </li>
       
    20 <li id="GUID-AD65EABD-573A-5A03-B59B-50A1DE7219DF"><p>user errors, such as
       
    21 an attempt to enter bad data in a dialog, an invalid action in, say, a word
       
    22 processor, or bad syntax in a source file</p> </li>
       
    23 </ul>
       
    24 <p>Program errors are checked by asserts (<codeph>__ASSERT_DEBUG</codeph> macro),
       
    25 and are signalled by a panic. Recovery from such errors involves re-writing
       
    26 part of the program that contained the error. </p>
       
    27 <p>Environment and user errors can be handled in broadly two ways:</p>
       
    28 <ul>
       
    29 <li id="GUID-7DAF8642-F413-5332-958C-A7B31C1BDD1F"><p>If they can be detected
       
    30 before an action is performed, then a return value other than <codeph>KErrNone</codeph> is
       
    31 a convenient means to signal the error.</p> <p>This method is simple to program,
       
    32 and cleanup requirements, if they exist at all, are often easy to identify
       
    33 and handle.</p> </li>
       
    34 <li id="GUID-4561F90D-E7C0-5D5C-AB33-4F2C25D7C4F1"><p>Alternatively, the program
       
    35 can use the exception handling and cleanup techniques discussed in this section.</p> <p>This
       
    36 method is more appropriate when the detection of an error occurs deep inside
       
    37 the processing of a requested action: if the error return value method were
       
    38 used, every function would have to return such an error and cleanup requirements
       
    39 would have to be handled for virtually every function call. The logic becomes
       
    40 repetitive and it’s easier to incorporate it into an exception-handling scheme.</p> </li>
       
    41 </ul>
       
    42 <p>When programming for possible environment or user error conditions, bear
       
    43 in mind both approaches for handling them, and choose the most suitable one.</p>
       
    44 <p>Applications must perform proper cleanup when an exception occurs, because
       
    45 they are designed to run for long periods (months or even years) without interruption
       
    46 or system re-boot. </p>
       
    47 </conbody></concept>