[559513]: impnotes / conditions.html Maximize Restore History

Download this file

conditions.html    54 lines (53 with data), 13.9 kB

 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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 9. Conditions
[CLHS-9]</title><link rel="stylesheet" href="impnotes.css" type="text/css" /><link rev="made" href="mailto:clisp-list@lists.sourceforge.net" /><meta name="generator" content="DocBook XSL Stylesheets V2005-10-07_10:16_snapshot" /><link rel="start" href="index.html" title="Implementation Notes for GNU CLISP" /><link rel="up" href="clhs-chapters.html" title="Part I. Chapters or the Common Lisp HyperSpec" /><link rel="prev" href="structures.html" title="Chapter 8. Structures&#10; [CLHS-8]" /><link rel="next" href="cond-nl.html" title="9.1. Embedded Newlines in Condition Reports&#10; [CLHS-9.1.3.1.3]" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 9. Conditions
[CLHS-9]</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="structures.html">Prev</a> </td><th width="60%" align="center">Part I. Chapters or the Common Lisp HyperSpec</th><td width="20%" align="right"> <a accesskey="n" href="cond-nl.html">Next</a></td></tr></table><hr /></div><div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="conditions"></a>Chapter 9. Conditions
<a href="http://www.lisp.org/HyperSpec/Body/chap-9.html" target="_top">[CLHS-9]</a></h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="cond-nl.html">9.1. Embedded Newlines in Condition Reports
[CLHS-9.1.3.1.3]</a></span></dt><dt><span class="section"><a href="cond-dict.html">9.2. The Conditions Dictionary
[CLHS-9.2]</a></span></dt></dl></div><p>When an error occurred, you are in a break loop. You can evaluate
forms as usual. The <span><strong class="command">help</strong></span> command (or help key if
there is one) lists the available <a href="debugger.html" title="25.1. Debugging Utilities&#10; [CLHS-25.1.2]">debugging
commands</a>.</p><p><a id="muffle-cerrors"></a><b>Macro <a href="conditions.html#muffle-cerrors"><code class="function">EXT:MUFFLE-CERRORS</code></a></b>The macro <code class="code">(<a href="conditions.html#muffle-cerrors"><code class="function">EXT:MUFFLE-CERRORS</code></a> {<em class="replaceable"><code>form</code></em>}*)</code>
executes the <em class="replaceable"><code>form</code></em>s; when a <a href="http://www.lisp.org/HyperSpec/Body/glo_c.html#continuable" target="_top">continuable</a> <a href="http://www.lisp.org/HyperSpec/Body/contyp_error.html" target="_top"><code class="classname">ERROR</code></a> occurs whose <a href="http://www.lisp.org/HyperSpec/Body/fun_abortcm_c_cm_use-value.html" target="_top"><code class="function">CONTINUE</code></a> <a href="http://www.lisp.org/HyperSpec/Body/syscla_restart.html" target="_top"><code class="classname">RESTART</code></a>
can be invoked non-interactively (this includes all <a href="http://www.lisp.org/HyperSpec/Body/glo_c.html#continuable" target="_top">continuable</a> <a href="http://www.lisp.org/HyperSpec/Body/contyp_error.html" target="_top"><code class="classname">ERROR</code></a>s signaled
by the function <a href="http://www.lisp.org/HyperSpec/Body/fun_cerror.html" target="_top"><code class="function">CERROR</code></a>), no message is printed, instead, the <a href="http://www.lisp.org/HyperSpec/Body/fun_abortcm_c_cm_use-value.html" target="_top"><code class="function">CONTINUE</code></a>
<a href="http://www.lisp.org/HyperSpec/Body/syscla_restart.html" target="_top"><code class="classname">RESTART</code></a> is invoked.</p><p><a id="appease-cerrors"></a><b>Macro <a href="conditions.html#appease-cerrors" class="olink"><code class="function">EXT:APPEASE-CERRORS</code></a></b>The macro <code class="code">(<a href="conditions.html#appease-cerrors" class="olink"><code class="function">EXT:APPEASE-CERRORS</code></a> {<em class="replaceable"><code>form</code></em>}*)</code>
executes the <em class="replaceable"><code>form</code></em>s; when a <a href="http://www.lisp.org/HyperSpec/Body/glo_c.html#continuable" target="_top">continuable</a> <a href="http://www.lisp.org/HyperSpec/Body/contyp_error.html" target="_top"><code class="classname">ERROR</code></a> occurs whose <a href="http://www.lisp.org/HyperSpec/Body/fun_abortcm_c_cm_use-value.html" target="_top"><code class="function">CONTINUE</code></a> <a href="http://www.lisp.org/HyperSpec/Body/syscla_restart.html" target="_top"><code class="classname">RESTART</code></a>
can be invoked non-interactively (this includes all <a href="http://www.lisp.org/HyperSpec/Body/glo_c.html#continuable" target="_top">continuable</a> <a href="http://www.lisp.org/HyperSpec/Body/contyp_error.html" target="_top"><code class="classname">ERROR</code></a>s <a href="http://www.lisp.org/HyperSpec/Body/fun_signal.html" target="_top"><code class="function">SIGNAL</code></a>ed
by the function <a href="http://www.lisp.org/HyperSpec/Body/fun_cerror.html" target="_top"><code class="function">CERROR</code></a>), it is reported as a <a href="http://www.lisp.org/HyperSpec/Body/contyp_warning.html" target="_top"><code class="classname">WARNING</code></a>, and the
<a href="http://www.lisp.org/HyperSpec/Body/fun_abortcm_c_cm_use-value.html" target="_top"><code class="function">CONTINUE</code></a> <a href="http://www.lisp.org/HyperSpec/Body/syscla_restart.html" target="_top"><code class="classname">RESTART</code></a> is invoked.</p><p><a id="abort-on-error"></a><b>Macro <a href="conditions.html#abort-on-error" class="olink"><code class="function">EXT:ABORT-ON-ERROR</code></a></b>The macro <code class="code">(<a href="conditions.html#abort-on-error" class="olink"><code class="function">EXT:ABORT-ON-ERROR</code></a> {<em class="replaceable"><code>form</code></em>}*)</code>
executes the <em class="replaceable"><code>form</code></em>s; when an <a href="http://www.lisp.org/HyperSpec/Body/contyp_error.html" target="_top"><code class="classname">ERROR</code></a> occurs,
or when a <span><strong class="keycap">Control</strong></span>-<span class="keysym">C</span> interrupt occurs,
the error message is printed and the <a href="http://www.lisp.org/HyperSpec/Body/res_abort.html" target="_top"><code class="function">ABORT</code></a> restart is invoked.
</p><p><a id="exit-on-error"></a><b>Macro <a href="conditions.html#exit-on-error" class="olink"><code class="function">EXT:EXIT-ON-ERROR</code></a></b>The macro <code class="code">(<a href="conditions.html#exit-on-error" class="olink"><code class="function">EXT:EXIT-ON-ERROR</code></a> {<em class="replaceable"><code>form</code></em>}*)</code>
executes the <em class="replaceable"><code>form</code></em>s; when an <a href="http://www.lisp.org/HyperSpec/Body/contyp_error.html" target="_top"><code class="classname">ERROR</code></a> occurs,
or when a <span><strong class="keycap">Control</strong></span>-<span class="keysym">C</span> interrupt occurs,
the error message is printed and <a href="http://clisp.cons.org" target="_top"><span><strong class="command">CLISP</strong></span></a> terminates with an error status.
</p><p><a id="err-pr-bt"></a><b>Variable <a href="conditions.html#err-pr-bt" class="olink"><code class="varname">CUSTOM:*REPORT-ERROR-PRINT-BACKTRACE*</code></a></b>When this variable is non-<a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a> the error message printed by
<a href="conditions.html#abort-on-error" class="olink"><code class="function">EXT:ABORT-ON-ERROR</code></a> and <a href="conditions.html#exit-on-error" class="olink"><code class="function">EXT:EXIT-ON-ERROR</code></a> includes the backtrace (stack).
</p><p><a id="global-handler"></a><b>Function <a href="conditions.html#global-handler" class="olink"><code class="function">EXT:SET-GLOBAL-HANDLER</code></a></b>The function <code class="code">(<a href="conditions.html#global-handler" class="olink"><code class="function">EXT:SET-GLOBAL-HANDLER</code></a> <em class="replaceable"><code>condition</code></em> handler)</code>
establishes a global handler for the <em class="replaceable"><code>condition</code></em>.
The <em class="replaceable"><code>handler</code></em> should be <a href="http://www.lisp.org/HyperSpec/Body/fun_funcall.html" target="_top"><code class="function">FUNCALL</code></a>able (a
<a href="http://www.lisp.org/HyperSpec/Body/syscla_symbol.html" target="_top"><code class="classname">SYMBOL</code></a> or a <a href="http://www.lisp.org/HyperSpec/Body/syscla_function.html" target="_top"><code class="classname">FUNCTION</code></a>). If it returns, the next applicable
handler is invoked, so if you do not want to land in the debugger, it
should <span class="strong"><strong>not</strong></span> return.
E.g., the option <code class="option"><a href="clisp.html#opt-on-error" class="olink">-on-error</a></code> <code class="option">abort</code> and the macro
<a href="conditions.html#abort-on-error" class="olink"><code class="function">EXT:ABORT-ON-ERROR</code></a> are implemented by installing the following handler:
</p><pre class="programlisting">(defun sys::abortonerror (condition)
(sys::report-error condition)
(invoke-restart (find-restart 'abort condition)))</pre><p>
When <em class="replaceable"><code>handler</code></em> is <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>, the handler
for <em class="replaceable"><code>condition</code></em> is removed and returned.
When <em class="replaceable"><code>condition</code></em> is also <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>, all global handlers are removed and returned
as a <a href="http://www.lisp.org/HyperSpec/Body/syscla_list.html" target="_top"><code class="classname">LIST</code></a>, which can then be passed to <a href="conditions.html#global-handler" class="olink"><code class="function">EXT:SET-GLOBAL-HANDLER</code></a> as the
first argument and the handlers re-established.</p><p><a id="without-global-handlers"></a><b>Macro <a href="conditions.html#without-global-handlers" class="olink"><code class="function">EXT:WITHOUT-GLOBAL-HANDLERS</code></a></b>The macro <code class="code">(<a href="conditions.html#without-global-handlers" class="olink"><code class="function">EXT:WITHOUT-GLOBAL-HANDLERS</code></a> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-4.html" target="_top"><code class="literal">&amp;BODY</code></a>
<em class="replaceable"><code>body</code></em>)</code> removes all global handlers, executes <em class="replaceable"><code>body</code></em>, and
then restores the handlers.</p><p><a id="with-restarts"></a><b>Macro <a href="conditions.html#with-restarts"><code class="function">EXT:WITH-RESTARTS</code></a></b>The macro <a href="conditions.html#with-restarts"><code class="function">EXT:WITH-RESTARTS</code></a> is like <a href="http://www.lisp.org/HyperSpec/Body/mac_restart-case.html" target="_top"><code class="function">RESTART-CASE</code></a>, except that the
forms are specified after the restart clauses instead of before them,
and the restarts created are not implicitly associated with any <a href="http://www.lisp.org/HyperSpec/Body/contyp_condition.html" target="_top"><code class="classname">CONDITION</code></a>.
<code class="code">(<a href="conditions.html#with-restarts"><code class="function">EXT:WITH-RESTARTS</code></a> ({<em class="replaceable"><code>restart-clause</code></em>}*) {<em class="replaceable"><code>form</code></em>}*)</code> is
therefore equivalent to <code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_restart-case.html" target="_top"><code class="function">RESTART-CASE</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/speope_progn.html" target="_top"><code class="function">PROGN</code></a> {<em class="replaceable"><code>form</code></em>}*)
{<em class="replaceable"><code>restart-clause</code></em>}*)</code>.</p></div><div class="bookinfo"><hr width="100%" /><table width="100%" summary="impnotes meta info"><th><td align="left">These notes document <a href="http://clisp.cons.org" target="_top"><span><strong class="command">CLISP</strong></span></a> version 2.37</td><td align="right">Last modified: 2006-01-02</td></th></table></div><div class="custom-footer"><hr width="100%" /><table width="100%"><tr><td align="left"><a href="http://clisp.cons.org"><img src="clisp.png" width="48" height="48" alt="[CLISP home]" /></a></td><td align="center"><a href="http://sourceforge.net/donate/index.php?group_id=1355"><img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" border="0" alt="[Support This Project]" /></a></td><td align="right"><a href="http://sourceforge.net"><img width="125" height="37" alt="[SourceForge]" src="http://sflogo.sourceforge.net/sflogo.php?group_id=1355&amp;type=2&amp;page=conditions" /></a></td></tr></table></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="structures.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="clhs-chapters.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="cond-nl.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 8. Structures
[CLHS-8] </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 9.1. Embedded Newlines in Condition Reports
[CLHS-9.1.3.1.3]</td></tr></table></div></body></html>