File: PolyMLException.html

package info (click to toggle)
polyml 5.6-8
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 31,892 kB
  • ctags: 34,453
  • sloc: cpp: 44,983; ansic: 24,520; asm: 14,850; sh: 11,730; makefile: 551; exp: 484; python: 253; awk: 91; sed: 9
file content (56 lines) | stat: -rw-r--r-- 2,817 bytes parent folder | download | duplicates (5)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The PolyML.Exception structure</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="docstyle.css" rel="stylesheet" type="text/css">
</head>

<body>
<ul class="nav">
	<li><a href="PolyMLCompiler.html">Previous</a></li>
	<li><a href="PolyMLStructure.html">Up</a></li>
	<li><a href="#">Next</a></li>
</ul>
<H2><STRONG><font face="Arial, Helvetica, sans-serif">The PolyML.Exception structure</font></STRONG></H2>
<p>The <span class="identifier">Exception</span> sub-structure contains functions 
that assist in tracing exceptions.</p>
<pre class="mainsig">structure Exception :
sig
    val exceptionLocation : exn -&gt; location option
    val raiseWithLocation : exn * location -&gt; 'a
    val reraise : exn -&gt; 'a

    val traceException : (unit -&gt; 'a) * (string list * exn -&gt; 'a) -&gt; 'a
	 val exception_trace : (unit -&gt; 'a) -&gt; 'a
end
</pre>
<p>Exception packets in Poly/ML normally contain information about the location, 
  typically the file name and line number, where the exception was raised. The 
  <span class="identifier">exceptionLocation</span> function extracts this information 
  if it is available. <span class="identifier">raiseWithLocation</span> can be 
  used to provide an explicit location and override the default. <span class="identifier">reraise</span> 
  is written in terms of <span class="identifier">exceptionLocation</span> and 
  <span class="identifier">raiseWithLocation</span>. It is typically used where 
  a function needs to catch an exception and wishes to raise it again after doing 
  some clean-up. Using the <span class="identifier">raise</span> instruction of 
  ML would set the location to be the clean-up code whereas <span class="identifier">reraise</span> 
  will retain the original location.</p>
<p><span class="identifier">exception_trace</span> and <span class="identifier">traceException</span> 
  can be used to produce information about the stack when an exception is raised. 
  They both take an argument that is a function to be executed and if an exception 
  is raised within the function that is not caught they produce information from 
  the stack. <span class="identifier">exception_trace</span> prints this to standard-output 
  whereas <span class="identifier">traceException</span> uses the second argument, 
  a function, and calls that with the list of function names and the exception 
  packet. Note that if the function being traced handles any exceptions the trace 
  will only show the stack from that point down.</p>
<p>&nbsp; </p>
<ul class="nav">
	<li><a href="PolyMLCompiler.html">Previous</a></li>
	<li><a href="PolyMLStructure.html">Up</a></li>
	<li><a href="#">Next</a></li>
</ul>

</body>
</html>