Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd5c3d824c3db63ffd9226c15941e6ad > files > 134

mozart-1.4.0-1mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>10.4 Exceptions</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="time.html#section.control.time">&lt;&lt; Prev</A></TD><TD><A href="node12.html">- Up -</A></TD><TD><A href="thread.html#section.control.threads">Next &gt;&gt;</A></TD></TR></TABLE><DIV id="section.control.exceptions"><H2><A name="section.control.exceptions">10.4 Exceptions</A></H2><P> The module <CODE>Exception</CODE> provides procedures to construct exceptions and raise them. </P><DIV class="apropos"><P class="margin">Special Exceptions</P><P> <A name="label726"></A> <A name="label727"></A> <A name="label728"></A> Any value may be raised as exception, although commonly only records are used. Some of these serve special purposes: <EM class="noindex">error exceptions</EM> are records with label <CODE>error</CODE>. These are raised when a programming error occurs; it is not recommended to catch these. <EM class="noindex">System exceptions</EM> are records with label <CODE>system</CODE>. These are raised when an unforeseeable runtime condition occurs; a file operations library might raise system exceptions when a file cannot be opened. It is recommended to always handle such exceptions. <EM class="noindex">Failure exceptions</EM> are records with label <CODE>failure</CODE>; these are raised when a tell operation fails. </P></DIV><DIV class="apropos"><P class="margin">Dispatch Fields</P><P> Both error and system exceptions have a <EM>dispatch field</EM>. This is the subtree at feature&nbsp;<CODE>1</CODE> of the exception record. This is usually a record further describing the exact condition that occurred. </P></DIV><DIV class="apropos"><P class="margin">Debug Information</P><P> If an exception is a record and has a feature <CODE>debug</CODE> with value <CODE><SPAN class="keyword">unit</SPAN></CODE>, then the implementation may replace (depending on the value of the property <CODE>ozconf<SPAN class="keyword">.</SPAN>errorDebug</CODE>) the corresponding subtree by implementation-dependent debugging information. This is to be printed out in the case of uncaught exceptions. </P></DIV><P> All procedures in the Base Environment only ever raise special-purpose exceptions as described above. </P><DL><DT><CODE>error</CODE> <A name="label729"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Exception<SPAN class="keyword">.</SPAN>error&nbsp;</CODE><CODE><I>X</I></CODE><CODE>&nbsp;</CODE><CODE>?<I>Y</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>returns an error exception record with dispatch field&nbsp;<CODE><I>X</I></CODE>. </P></DD><DT><CODE>system</CODE> <A name="label730"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Exception<SPAN class="keyword">.</SPAN>system&nbsp;</CODE><CODE><I>X</I></CODE><CODE>&nbsp;</CODE><CODE>?<I>Y</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>returns a system exception record with dispatch field&nbsp;<CODE><I>X</I></CODE>. </P></DD><DT><CODE>failure</CODE> <A name="label731"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Exception<SPAN class="keyword">.</SPAN>failure&nbsp;</CODE><CODE><I>X</I></CODE><CODE>&nbsp;</CODE><CODE>?<I>Y</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>returns a failure exception. The value&nbsp;<CODE><I>X</I></CODE> may give a hint on why failure occurred; implementations may store this inside the constructed exception's <CODE>debug</CODE> field. </P></DD><DT><A name="label732"></A><SPAN class="index"><CODE>Raise</CODE></SPAN> <A name="label733"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Exception<SPAN class="keyword">.</SPAN><SPAN class="string">'raise'</SPAN>&nbsp;</CODE><CODE><I>X</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>raises <CODE><I>X</I></CODE> as an exception. </P></DD><DT><CODE>raiseError</CODE> <A name="label734"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Exception<SPAN class="keyword">.</SPAN>raiseError&nbsp;</CODE><CODE><I>X</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>wraps <CODE><I>X</I></CODE> into an error exception and raises this. This procedure can be defined as follows, except that it always add debug informations: </P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Exception.raiseError</SPAN>&nbsp;X}<BR>&nbsp;&nbsp;&nbsp;{Exception<SPAN class="keyword">.</SPAN><SPAN class="string">'raise'</SPAN>&nbsp;{AdjoinAt&nbsp;{Exception<SPAN class="keyword">.</SPAN>error&nbsp;X}&nbsp;debug&nbsp;<SPAN class="keyword">unit</SPAN>}}<BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P> </P></DD></DL><P> </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="time.html#section.control.time">&lt;&lt; Prev</A></TD><TD><A href="node12.html">- Up -</A></TD><TD><A href="thread.html#section.control.threads">Next &gt;&gt;</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys&nbsp;Duchier</A>, <A href="http://www.ps.uni-sb.de/~kornstae/">Leif&nbsp;Kornstaedt</A> and&nbsp;<A href="http://www.ps.uni-sb.de/~schulte/">Christian&nbsp;Schulte</A><BR><SPAN class="version">Version 1.4.0 (20090610)</SPAN></ADDRESS></BODY></HTML>