/usr/share/doc/libtse3-dev/Error.html is in libtse3-dev 0.3.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | <html>
<head>
<title>TSE3 error handling</title>
</head>
<body bgcolor=#ffffff text=#000000>
<table width=100% cellspacing=0 cellpadding=1 border=0 bgcolor=#000000><tr><td>
<table width=100% cellspacing=0 cellpadding=1 border=0><tr><td valign=center bgcolor=#c8d559>
<table width=100% cellspacing=0 cellpadding=0 border=0><tr>
<td align=left width=30%><b> TSE3 documentation<b></td>
<td align=center width=30%>Version 0.3.1</td>
<td align=right width=30%>
<a href="index.html"><b>Index</b></a>
<a href="api/index.html">API</a>
<a href="Version.html">Version</a>
<a href="Structure.html">Structure</a>
</td>
</tr></table>
</td></tr></table>
</td></tr></table>
<h1>TSE3 error handling</h1>
<h3>C++ exceptions</h3>
<p>
The TSE3 library uses exceptions to indicate unrecoverable errors.
The member functions which raise errors are clearly indicatated in the
documentation.
<p>
For this reason it is important that you write your application with
exception handlers (at the very least, enclose your <code>main</code>
function in a <code>try</code>/<code>catch</code> block, otherwise
any errors will lead to a segfault.
<p>
Every different TSE3 error is derived from a common base class,
<code>Error</code>. This class in turn derives from the standard library
exception class <code>exception</code>. It is up to you at what level
you catch any exception (i.e. specific subclass like
<code>PhraseListError</code>, all TSE3 errors with <code>Error</code> or
all library exceptions with <code>exception</code>).
<p>
The suggested format for catching errors is as shown below:
<p>
<pre>
try
{
// perform TSE3 activity that might throw an exception
phraseList.insert(newPhrase);
}
catch (const Error &e)
{
// do some error handling
cerr << "An error occured of type " << e.reason << endl;
exit(1);
}
</pre>
<p>
That is, catch by const reference. Of course, you will probably want
to catch a more specific exception type; in the above example a
<code>PhraseListError</code>.
<h3>Error reason codes</h3>
<p>
The base <code>Error</code> class includes a reason code parameter. You
may therefore distinguish the cause of the error in two ways, by
type of exception caught or by inspecting the reason code. Reason codes
are defined by the <code>ErrorCode</code> enum type.
<p>
The reason for this (seemingly redundant) reason code is simple: when
writing an application it is easier to work out which internationalised
error string to show to the user on reciept of an exception by indexing
into a table by reason code, rather that trying to convert an exception
type into a string.
<p>
The TSE3 library provides a set of standard English string representations
of each <code>ErrorCode</code> value.
<h3>General information</h3>
<p>
The error class definitions are located in the file
<code>tse3/Error.h</code>. The other TSE3 header files do not include
this directly, so if you need to handle TSE3 exceptions you will need to
<code>#include</code> this in your own code.
<p>
Note that some erroneous operations, like attempting to remove a
<code>Phrase</code> from the <code>PhraseList</code> which was never
inserted, result in no error being raised and the method returning silently.
Such occurences are clearly marked in the documentation.
<h3>Memory allocation errors</h3>
<p>
Since TSE3 error handling is based on the C++ exception mechanism, memory
allocation failure is also expected to raise an exception
(<code>std::bad_alloc</code>). For this reason, you will not see code that
checks the return value of <code>new</code> against the value zero in the
TSE3 source.
<p>
In fact, TSE3 does not even attempt to catch a <code>bad_alloc</code> since
if there is a memory leak, there really is no useful work that the
library can perform - it is probably too late to gracefully degrade. It
is up to the library user to catch any occurance of <code>bad_alloc</code>
and warn the application user, if possible.
<body bgcolor=#ffffff text=#000000>
<table width=100% cellspacing=0 cellpadding=1 border=0 bgcolor=#000000><tr><td>
<table width=100% cellspacing=0 cellpadding=1 border=0><tr><td valign=center bgcolor=#c8d559>
<table width=100% cellspacing=0 cellpadding=0 border=0><tr>
<td align=left width=30%> © Pete Goodliffe, 2001-2003</td>
<td align=center width=30%><a href="Copyright.html">Copyright</a></td>
<td align=right width=30%><a href="Psalm150.html">Psalm 150</a> </td>
</tr></table>
</td></tr></table>
</td></tr></table>
</body>
</html>
|