The Use of C++ Exception Handling Constructs:
A Comprehensive Study

Abstract

Exception handling (EH) is a well known mechanism that improves software reliability in a modular way--- allowing a better separation of the code that deals with exceptional conditions. Although the current approach for exception handling has been conceived almost 40 years ago, there exist language particularities that change the way developers use this mechanism. This paper reports on the use of the exception handing mechanism in C++, after analyzing 65 open-source projects and considering more than 34 million lines of C++ code. Our main conclusion is that, independently of the project category (e.g. GUI toolkit, office suite, database system) or project complexity (in terms of lines-of-code), dealing with exceptional conditions using C++ constructs is considered either (a) a less important concern or (b) a bad practice that should be completely avoided.
[pdf]

Tool support

The exception-handling data described in the paper was collected using our static analysis tool (exceptionChecker.jar). The basic usage is:

$ java -jar exceptionChecker.jar -check -projectList projects.csv --output reports

This command line genarete several output files within the reports directory. A projects.csv must have a structure like:

mico; r-2012-07-18; projects/mico/r-2012-07-18; 306108; 91.10; 1996;2010 
omniORB; r-4.1.7; projects/omniORB/omniORB-4.1.7; 111570; 76.65; 2012; 2014

, where the last four columns describe:

Subject Systems

In the following table, we present the specific versions of the systems considered in this study, together with some summary data about the projects.
Project Revision SLOC CppRatio Statements TryCatchBlocks Handlers TryStatements CatchStatements
1 alephone r-20140104 163284 78.58 75817 23 26 638 75
2 boost r-1.53.0 2048746 95.39 748836 1725 7465 42922 9245
3 chromium r-3.0.190.2 1312808 60.20 448992 0 0 0 0
4 clang 3.4.2 800471 78.34 635922 71 88 460 45
5 clementinePlayer r-1.2.1 294501 62.96 130775 8 9 79 16
6 codeBlocks r-13.1.2 727875 90.35 360044 48 55 607 91
7 codeLite r-6.0 538681 74.44 339245 207 216 3874 673
8 commonCPP r-2.1.8.1 40783 71.64 11191 10 11 167 26
9 crystalspace r-2.0 1095925 73.05 636017 1 1 7 1
10 eMule r-0.5.0 213268 89.78 125569 264 318 12772 879
11 emtg r-8 27498 76.98 14950 6 6 90 12
12 filezilla r-3.8.1 129107 62.76 75831 0 0 0 0
13 firebird r-2.5.2 1030309 45.20 362911 494 516 14990 1248
14 firefox r-26.0 5498992 60.14 2375516 207 212 4820 223
15 gcc r-4.8.2 4751942 14.53 1939141 1308 2009 12753 2599
16 gmat r-2013a 378470 81.95 161133 435 463 8740 1016
17 gnash 0.8.9 148088 80.49 87909 120 125 3296 221
18 hhvm r-2.3.3 1028209 49.90 374192 257 325 4990 756
19 hotspot b147 678341 70.44 330052 0 0 0 0
20 hseg r-1.4.7 26011 100.00 12640 0 0 0 0
21 inkscape r-0.4.8 422764 87.14 240536 67 80 729 153
22 kate trunk 126650 90.02 70979 0 0 0 0
23 kdelibs r-4.9.2 776650 97.26 410962 17 17 299 34
24 kderuntime r-4.9.2 110813 96.01 62013 0 0 0 0
25 kdeworkspace r-4.9.2 407960 90.26 223207 0 0 0 0
26 kdev trunk 106237 98.36 65604 2 2 60 4
27 keepass r-1.26 54414 100.00 33463 9 9 105 16
28 kile r-2.1.3 38265 98.45 25620 1 1 18 1
29 kmplayer r-0.11.3d 37453 91.85 20657 0 0 0 0
30 koffice r-2.3.3 976012 97.85 571640 406 616 4898 1726
31 konqueror r-4.5.3 31882 99.84 17605 0 0 0 0
32 libreoffice r-4.2.0.2 4632078 87.76 2380799 7520 9043 123369 10197
33 llvm r-3.4.2 905553 71.48 459567 1 2 9 2
34 mediaPlayerCentral r-1.7.0 569481 71.78 171603 61 67 1445 167
35 mico r-2012-07-18 336017 91.10 333226 1384 2346 19860 4450
36 mixxxx r-1.11.0 257501 82.76 71685 3 4 31 7
37 mongo r-2.4.9 920935 80.57 370377 650 857 10629 2161
38 mozjs r-24.2.0 695176 72.11 298080 9 9 98 15
39 museScore trunk 230736 96.86 146599 22 23 707 39
40 myserver r-011 64051 62.40 32316 171 178 3121 229
41 nodeJS r-0.10.29 963414 34.77 320101 0 0 0 0
42 nodeWebkit r-0.9.2 21437 98.28 9529 0 0 0 0
43 octave r-3.8.1 392819 76.80 135466 25 31 242 45
44 omniORB r-4.1.7 145565 76.65 64463 219 349 3803 873
45 openOffice r-401 2963117 90.02 1571346 4816 5713 79469 6877
46 opencv r-2.4.8 718155 74.21 286986 327 441 6344 691
47 openPegasus r-2.13.0 529291 88.85 234136 2488 3108 40359 6456
48 otter r-0.1.01 13814 100.00 8229 0 0 0 0
49 phantomjs r-1.9.2 1913966 85.59 796022 9 13 91 29
50 phc r-0.3.0.1 170164 63.53 67409 3 3 32 2
51 qpid trunk 548502 26.45 72927 454 540 7200 943
52 qt r-4.5.3 1984754 81.55 933127 43 52 533 136
53 rekonq r-2.3.2 21479 99.98 11715 0 0 0 0
54 rethinkdb 1.9.0 250228 54.60 102055 172 288 3091 411
55 rocksdb r-2.6.fb 57703 78.19 22914 11 14 103 37
56 textedit trunk 15749 92.01 9088 14 17 180 34
57 thrift r-0.9.1 140296 48.61 56292 116 144 1511 394
58 tortoise r-1.6.14 810180 29.86 340151 54 55 1367 59
59 ucommon r-6.1.8 56167 77.94 19355 0 0 0 0
60 virtualBox r-4.13.2 4059064 27.25 898051 198 223 9013 269
61 visionWorkbench r-2.0.0 113001 88.19 51087 120 137 2083 265
62 webkit trunk 1681262 79.65 518395 295 296 6583 299
63 winDJView r-2.0.1 79777 99.49 43978 14 20 258 20
64 wxWidgets r-3.0.0 1084291 82.19 220927 8 14 71 18
65 xalan r-1.9.0 148729 97.58 36689 68 89 1955 255