File: Error.html

package info (click to toggle)
python-libtrace 1.6%2Bgit20161027-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,124 kB
  • ctags: 1,357
  • sloc: ansic: 6,890; python: 3,228; makefile: 70; sh: 49
file content (12 lines) | stat: -rw-r--r-- 2,231 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html><head>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Libtrace Errors</title>

<meta name="generator" content="KompoZer" />
<link rel="stylesheet" type="text/css" href="plt-doc.css" /></head><body>
<h2 style="text-align: left;">Handling libtrace errors</h2><big><span style="font-weight: bold;">Exception plt_exc_libtrace</span></big><br /><br /><span style="font-style: italic;">plt_libtrace_exc&nbsp;</span> is a subclass of Python's <span style="font-style: italic;">SystemError</span> exception. &nbsp;Python-libtrace checks for errors during operations on traces, see the <span style="font-style: italic;">Trace</span> and <span style="font-style: italic;">OutputTrace</span> page for further information.<br /><br />For most purposes you can simply invoke the <span style="font-style: italic;">Trace</span> and <span style="font-style: italic;">OutputTrace</span> methods, knowing that if python-libtrace encounters an error it will throw a <span style="font-style: italic;">LibtraceError</span> and <span style="font-style: italic;">exit</span>, with the Python interpreter printing a diagnostic line to tell you what it thinks caused the problem.<br />Alternatively, you can catch the exception using a "try-except block," like this:

<br /><br />&nbsp; &nbsp; &nbsp;<span style="font-style: italic;">try:</span><br style="font-style: italic;" /><span style="font-style: italic;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;f = plt.trace(ARGV[0])</span><br style="font-style: italic;" /><span style="font-style: italic;">&nbsp; &nbsp; &nbsp;except:</span><br style="font-style: italic;" /><span style="font-style: italic;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print "helpful message\n"</span><br style="font-style: italic;" /><span style="font-style: italic;">&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;sys.exc_clear()</span><br style="font-style: italic;" /><span style="font-style: italic;"><br /></span>Here, the&nbsp;<span style="font-style: italic;">sys.exc_clear() </span>statement simply clears the exception history.<p>Nevil Brownlee<br />Mon, 30 Jun 14 (NZST)</p>
</body></html>