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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset= ISO-8859-1">
<TITLE>
Module Printexc: a catch-all exception handler
</TITLE>
</HEAD>
<BODY >
<A HREF="manual048.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual050.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<HR>
<H2>17.19 Module <TT>Printexc</TT>: a catch-all exception handler</H2><A NAME="s:Printexc"></A>
<A NAME="@manual405"></A><PRE>
val catch: ('a -> 'b) -> 'a -> 'b
</PRE>
<A NAME="@manual406"></A><BLOCKQUOTE>
<CODE>Printexc.catch fn x</CODE> applies <CODE>fn</CODE> to <CODE>x</CODE> and returns the result.
If the evaluation of <CODE>fn x</CODE> raises any exception, the
name of the exception is printed on standard error output,
and the programs aborts with exit code 2.
Typical use is <CODE>Printexc.catch main ()</CODE>, where <CODE>main</CODE>, with type
<CODE>unit->unit</CODE>, is the entry point of a standalone program.
This catches and reports any exception that escapes the program.
</BLOCKQUOTE>
<PRE>
val print: ('a -> 'b) -> 'a -> 'b
</PRE>
<A NAME="@manual407"></A><BLOCKQUOTE>
Same as <CODE>catch</CODE>, but re-raise the stray exception after
printing it, instead of aborting the program.
</BLOCKQUOTE>
<PRE>
val to_string : exn -> string
</PRE>
<A NAME="@manual408"></A><BLOCKQUOTE>
<CODE>Printexc.to_string e</CODE> returns a string representation of <CODE>e</CODE>.
</BLOCKQUOTE>
<HR>
<A HREF="manual048.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual050.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
</BODY>
</HTML>
|