<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.10">
<title>MLtonExn</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">


<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css">
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20201002</a>
</div>
</div>
<div id="header">
<h1>MLtonExn</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="k">signature</span><span class="w"> </span><span class="n">MLTON_EXN</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">   </span><span class="k">sig</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">addExnMessager</span><span class="p">:</span><span class="w"> </span><span class="p">(</span><span class="n">exn</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">string</span><span class="w"> </span><span class="n">option</span><span class="p">)</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">unit</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">history</span><span class="p">:</span><span class="w"> </span><span class="n">exn</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">string</span><span class="w"> </span><span class="n">list</span><span class="w"></span>

<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">defaultTopLevelHandler</span><span class="p">:</span><span class="w"> </span><span class="n">exn</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">&#39;a</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">getTopLevelHandler</span><span class="p">:</span><span class="w"> </span><span class="n">unit</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="p">(</span><span class="n">exn</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">unit</span><span class="p">)</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">setTopLevelHandler</span><span class="p">:</span><span class="w"> </span><span class="p">(</span><span class="n">exn</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">unit</span><span class="p">)</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">unit</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">topLevelHandler</span><span class="p">:</span><span class="w"> </span><span class="n">exn</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">&#39;a</span><span class="w"></span>
<span class="w">   </span><span class="k">end</span><span class="w"></span>
</pre></div></div></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">addExnMessager f</span>
</p>
<div class="paragraph"><p>adds <span class="monospaced">f</span> as a pretty-printer to be used by <span class="monospaced">General.exnMessage</span> for
converting exceptions to strings.  Messagers are tried in order from
most recently added to least recently added.</p></div>
</li>
<li>
<p>
<span class="monospaced">history e</span>
</p>
<div class="paragraph"><p>returns call stack at the point that <span class="monospaced">e</span> was first raised.  Each
element of the list is a file position.  The elements are in reverse
chronological order, i.e. the function called last is at the front of
the list.</p></div>
<div class="paragraph"><p><span class="monospaced">history e</span> will return <span class="monospaced">[]</span> unless the program is compiled with
<span class="monospaced">-const 'Exn.keepHistory true'</span>.</p></div>
</li>
<li>
<p>
<span class="monospaced">defaultTopLevelHandler e</span>
</p>
<div class="paragraph"><p>function that behaves as the default top level handler; that is, print
out the unhandled exception message for <span class="monospaced">e</span> and exit.</p></div>
</li>
<li>
<p>
<span class="monospaced">getTopLevelHandler ()</span>
</p>
<div class="paragraph"><p>get the top level handler.</p></div>
</li>
<li>
<p>
<span class="monospaced">setTopLevelHandler f</span>
</p>
<div class="paragraph"><p>set the top level handler to the function <span class="monospaced">f</span>.  The function <span class="monospaced">f</span>
should not raise an exception or return normally.</p></div>
</li>
<li>
<p>
<span class="monospaced">topLevelHandler e</span>
</p>
<div class="paragraph"><p>behaves as if the top level handler received the exception <span class="monospaced">e</span>.</p></div>
</li>
</ul></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>
