aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2007-07-14 18:34:22 +0000
committerRichard M. Stallman2007-07-14 18:34:22 +0000
commitbe44b862badaad8cc0a498c0f5dc9cce2a352e61 (patch)
tree0d5347a7feec0961a700dea935c6ad9c17aa1b6a
parent8d3719940eb01f6a63cfe2b6e05bb97b85627e3a (diff)
downloademacs-be44b862badaad8cc0a498c0f5dc9cce2a352e61.tar.gz
emacs-be44b862badaad8cc0a498c0f5dc9cce2a352e61.zip
(Handling Errors): Document `debug' in handler list.
-rw-r--r--lispref/ChangeLog4
-rw-r--r--lispref/control.texi49
2 files changed, 38 insertions, 15 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog
index 61bc10c1afc..6a824f8deaf 100644
--- a/lispref/ChangeLog
+++ b/lispref/ChangeLog
@@ -1,3 +1,7 @@
12007-07-14 Richard Stallman <rms@gnu.org>
2
3 * control.texi (Handling Errors): Document `debug' in handler list.
4
12007-07-09 Richard Stallman <rms@gnu.org> 52007-07-09 Richard Stallman <rms@gnu.org>
2 6
3 * files.texi (Magic File Names): Rewrite previous change. 7 * files.texi (Magic File Names): Rewrite previous change.
diff --git a/lispref/control.texi b/lispref/control.texi
index 4c469a10368..e99a6329f3e 100644
--- a/lispref/control.texi
+++ b/lispref/control.texi
@@ -893,6 +893,12 @@ establishing an error handler, with the special form
893This deletes the file named @var{filename}, catching any error and 893This deletes the file named @var{filename}, catching any error and
894returning @code{nil} if an error occurs. 894returning @code{nil} if an error occurs.
895 895
896 The @code{condition-case} construct is often used to trap errors that
897are predictable, such as failure to open a file in a call to
898@code{insert-file-contents}. It is also used to trap errors that are
899totally unpredictable, such as when the program evaluates an expression
900read from the user.
901
896 The second argument of @code{condition-case} is called the 902 The second argument of @code{condition-case} is called the
897@dfn{protected form}. (In the example above, the protected form is a 903@dfn{protected form}. (In the example above, the protected form is a
898call to @code{delete-file}.) The error handlers go into effect when 904call to @code{delete-file}.) The error handlers go into effect when
@@ -920,15 +926,33 @@ the two gets to handle it.
920 If an error is handled by some @code{condition-case} form, this 926 If an error is handled by some @code{condition-case} form, this
921ordinarily prevents the debugger from being run, even if 927ordinarily prevents the debugger from being run, even if
922@code{debug-on-error} says this error should invoke the debugger. 928@code{debug-on-error} says this error should invoke the debugger.
923@xref{Error Debugging}. If you want to be able to debug errors that are
924caught by a @code{condition-case}, set the variable
925@code{debug-on-signal} to a non-@code{nil} value.
926 929
927 When an error is handled, control returns to the handler. Before this 930 If you want to be able to debug errors that are caught by a
928happens, Emacs unbinds all variable bindings made by binding constructs 931@code{condition-case}, set the variable @code{debug-on-signal} to a
929that are being exited and executes the cleanups of all 932non-@code{nil} value. You can also specify that a particular handler
930@code{unwind-protect} forms that are exited. Once control arrives at 933should let the debugger run first, by writing @code{debug} among the
931the handler, the body of the handler is executed. 934conditions, like this:
935
936@example
937@group
938(condition-case nil
939 (delete-file filename)
940 ((debug error) nil))
941@end group
942@end example
943
944@noindent
945The effect of @code{debug} here is only to prevent
946@code{condition-case} from suppressing the call to the debugger. Any
947given error will invoke the debugger only if @code{debug-on-error} and
948the other usual filtering mechanisms say it should. @xref{Error Debugging}.
949
950 Once Emacs decides that a certain handler handles the error, it
951returns control to that handler. To do so, Emacs unbinds all variable
952bindings made by binding constructs that are being exited, and
953executes the cleanups of all @code{unwind-protect} forms that are
954being exited. Once control arrives at the handler, the body of the
955handler executes normally.
932 956
933 After execution of the handler body, execution returns from the 957 After execution of the handler body, execution returns from the
934@code{condition-case} form. Because the protected form is exited 958@code{condition-case} form. Because the protected form is exited
@@ -937,12 +961,6 @@ execution at the point of the error, nor can it examine variable
937bindings that were made within the protected form. All it can do is 961bindings that were made within the protected form. All it can do is
938clean up and proceed. 962clean up and proceed.
939 963
940 The @code{condition-case} construct is often used to trap errors that
941are predictable, such as failure to open a file in a call to
942@code{insert-file-contents}. It is also used to trap errors that are
943totally unpredictable, such as when the program evaluates an expression
944read from the user.
945
946 Error signaling and handling have some resemblance to @code{throw} and 964 Error signaling and handling have some resemblance to @code{throw} and
947@code{catch} (@pxref{Catch and Throw}), but they are entirely separate 965@code{catch} (@pxref{Catch and Throw}), but they are entirely separate
948facilities. An error cannot be caught by a @code{catch}, and a 966facilities. An error cannot be caught by a @code{catch}, and a
@@ -960,7 +978,8 @@ error occurs during @var{protected-form}.
960 978
961Each of the @var{handlers} is a list of the form @code{(@var{conditions} 979Each of the @var{handlers} is a list of the form @code{(@var{conditions}
962@var{body}@dots{})}. Here @var{conditions} is an error condition name 980@var{body}@dots{})}. Here @var{conditions} is an error condition name
963to be handled, or a list of condition names; @var{body} is one or more 981to be handled, or a list of condition names (which can include @code{debug}
982to allow the debugger to run before the handler); @var{body} is one or more
964Lisp expressions to be executed when this handler handles an error. 983Lisp expressions to be executed when this handler handles an error.
965Here are examples of handlers: 984Here are examples of handlers:
966 985