|
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-1171C47F-D7F3-5A49-B191-DB6CB7C84DC8" xml:lang="en"><title>Where |
|
13 to put trap harnesses?</title><shortdesc>Describes the criteria that should be taken into account when deciding |
|
14 where to put a trap harness.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
15 <p>Trap harnesses can be nested. If a function leaves, control goes to the |
|
16 most recent trap harness in the call stack. This allows independent sub-modules |
|
17 to do their own exception handling. Effective trap programming requires that |
|
18 the unit of recovery be correctly identified. </p> |
|
19 <p>The most basic option is to rely on the top-level trap harness provided |
|
20 as part of the application framework for all GUI programs. If a leave occurs, |
|
21 and it is not handled by any explicitly coded harness, the framework displays |
|
22 an error message corresponding to the leave code.</p> |
|
23 <p>For some applications, the unit of recovery may be the processing of any |
|
24 user command. In a particular application, the unit of recovery may be associated |
|
25 with part of the processing of a particular command — a much finer-grain |
|
26 approach.</p> |
|
27 <p>Coding a coarse-grain unit of recovery has the advantage of only one trap |
|
28 harness and recovery code, but the disadvantage that recovery code may be |
|
29 general and complex, and the danger that a small error leads to catastrophic |
|
30 results for a user (e.g. if not enough memory to apply bold formatting resulted |
|
31 in termination of the word processor with loss of data!).</p> |
|
32 <p>Coding too fine-grain units of recovery results in many trap harnesses, |
|
33 lots of recovery code which may require individual attention in each case, |
|
34 and potentially significantly increased code size.</p> |
|
35 <p>The correct choice is application-specific. For large applications, there |
|
36 may be a single course-grain unit of recovery, with other harnesses in particular |
|
37 places. </p> |
|
38 </conbody></concept> |