~ubuntu-branches/ubuntu/intrepid/swi-prolog/intrepid

« back to all changes in this revision

Viewing changes to man/Manual/excepthook.html

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2008-05-14 02:47:49 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080514024749-out53uysriunvn32
Tags: 5.6.55-1
* New upstream release.
* Use correct shared object file extension on HPPA to fix FTBFS on this
  architecture since 5.6.53-2. Patch backported from upstream repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
<HTML>
4
4
<HEAD>
5
 
<TITLE>SWI-Prolog 5.6.53 Reference Manual: Section B.3</TITLE><LINK REL=home HREF="index.html">
 
5
<TITLE>SWI-Prolog 5.6.55 Reference Manual: Section B.3</TITLE><LINK REL=home HREF="index.html">
6
6
<LINK REL=contents HREF="Contents.html">
7
7
<LINK REL=index HREF="DocIndex.html">
8
8
<LINK REL=previous HREF="tracehook.html">
132
132
 
133
133
<A NAME="sec:excepthook"></A>
134
134
 
135
 
<P>The hook <A NAME="idx:prologexceptionhook4:1544"></A><A class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</A> 
 
135
<P>The hook <A NAME="idx:prologexceptionhook4:1548"></A><A class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</A> 
136
136
has been introduced in SWI-Prolog 5.6.5 to provide dedicated exception 
137
137
handling facilities for application frameworks. For example 
138
138
non-interactive server applications that wish to provide extensive 
145
145
This hook predicate, if defined in the module <CODE>user</CODE>, is 
146
146
between raising an exception and handling it. It is intended to allow a 
147
147
program adding additional context to an exception to simplify diagnosing 
148
 
the problem. <VAR>ExceptionIn</VAR> is the exception term as raised by <A NAME="idx:throw1:1545"></A><A class="pred" href="exception.html#throw/1">throw/1</A> 
 
148
the problem. <VAR>ExceptionIn</VAR> is the exception term as raised by <A NAME="idx:throw1:1549"></A><A class="pred" href="exception.html#throw/1">throw/1</A> 
149
149
or one of the bullt-in predicates. The output argument <VAR>ExceptionOut</VAR> 
150
150
describes the exception that is actually raised. <VAR>Frame</VAR> is the 
151
 
innermost frame. See <A NAME="idx:prologframeattribute3:1546"></A><A class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</A> 
 
151
innermost frame. See <A NAME="idx:prologframeattribute3:1550"></A><A class="pred" href="manipstack.html#prolog_frame_attribute/3">prolog_frame_attribute/3</A> 
152
152
and the library
153
153
<CODE>library(prolog_stack)</CODE> for getting information from this.
154
154
<VAR>CatcherFrame</VAR> is a reference to the frame calling the matching
155
 
<A NAME="idx:catch3:1547"></A><A class="pred" href="exception.html#catch/3">catch/3</A> 
 
155
<A NAME="idx:catch3:1551"></A><A class="pred" href="exception.html#catch/3">catch/3</A> 
156
156
or <CODE>none</CODE> of the exception is not caught.
157
157
 
158
158
<P>The hook is run in `nodebug' mode. If it succeeds <VAR>ExceptionOut</VAR> 
161
161
recursively. The hook is <EM>not</EM> allowed to modify <VAR>ExceptionOut</VAR> 
162
162
in such as way that it no longer unifies with the catching frame.
163
163
 
164
 
<P>Typically, <A NAME="idx:prologexceptionhook4:1548"></A><A class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</A> 
 
164
<P>Typically, <A NAME="idx:prologexceptionhook4:1552"></A><A class="pred" href="excepthook.html#prolog_exception_hook/4">prolog_exception_hook/4</A> 
165
165
is used to fill the second argument of <CODE>error(Formal, Context)</CODE> 
166
166
exceptions. <VAR>Formal</VAR> is defined by the ISO standard, while 
167
167
SWI-Prolog defines <VAR>Context</VAR> as a term <CODE>context(Location, 
173
173
a quick test of the environment before starting expensive gathering 
174
174
information on the state of the program.
175
175
 
176
 
<P>The hook can call <A NAME="idx:trace0:1549"></A><A class="pred" href="debugger.html#trace/0">trace/0</A> 
 
176
<P>The hook can call <A NAME="idx:trace0:1553"></A><A class="pred" href="debugger.html#trace/0">trace/0</A> 
177
177
to enter trace mode immediately. For example imagine an application 
178
178
performing an unwanted division by zero while all other errors are 
179
179
expected and handled. We can force the debugger using the hook 
180
 
definition below. Run the program in debug mode (see <A NAME="idx:debug0:1550"></A><A class="pred" href="debugger.html#debug/0">debug/0</A>) 
 
180
definition below. Run the program in debug mode (see <A NAME="idx:debug0:1554"></A><A class="pred" href="debugger.html#debug/0">debug/0</A>) 
181
181
to preserve as much as possible of the error context.
182
182
 
183
183
<PRE class="code">