@error{} peculiar error: "My unknown error condition"
@error{} peculiar error: "My unknown error condition"
@end group
@end group
@end smallexample
@end example
@end defun
@end defun
@cindex CL note---no continuable errors
@cindex CL note---no continuable errors
...
@@ -990,7 +988,7 @@ to allow the debugger to run before the handler); @var{body} is one or more
...
@@ -990,7 +988,7 @@ to allow the debugger to run before the handler); @var{body} is one or more
Lisp expressions to be executed when this handler handles an error.
Lisp expressions to be executed when this handler handles an error.
Here are examples of handlers:
Here are examples of handlers:
@smallexample
@example
@group
@group
(error nil)
(error nil)
...
@@ -1000,7 +998,7 @@ Here are examples of handlers:
...
@@ -1000,7 +998,7 @@ Here are examples of handlers:
(message
(message
"Either division by zero or failure to open a file"))
"Either division by zero or failure to open a file"))
@end group
@end group
@end smallexample
@end example
Each error that occurs has an @dfn{error symbol} that describes what
Each error that occurs has an @dfn{error symbol} that describes what
kind of error it is. The @code{error-conditions} property of this
kind of error it is. The @code{error-conditions} property of this
...
@@ -1033,9 +1031,9 @@ Sometimes it is necessary to re-throw a signal caught by
...
@@ -1033,9 +1031,9 @@ Sometimes it is necessary to re-throw a signal caught by
@code{condition-case}, for some outer-level handler to catch. Here's
@code{condition-case}, for some outer-level handler to catch. Here's
how to do that:
how to do that:
@smallexample
@example
(signal (car err) (cdr err))
(signal (car err) (cdr err))
@end smallexample
@end example
@noindent
@noindent
where @code{err} is the error description variable, the first argument
where @code{err} is the error description variable, the first argument
...
@@ -1054,7 +1052,7 @@ Here is an example of using @code{condition-case} to handle the error
...
@@ -1054,7 +1052,7 @@ Here is an example of using @code{condition-case} to handle the error
that results from dividing by zero. The handler displays the error
that results from dividing by zero. The handler displays the error
message (but without a beep), then returns a very large number.
message (but without a beep), then returns a very large number.
@smallexample
@example
@group
@group
(defun safe-divide (dividend divisor)
(defun safe-divide (dividend divisor)
(condition-case err
(condition-case err
...
@@ -1075,22 +1073,24 @@ message (but without a beep), then returns a very large number.
...
@@ -1075,22 +1073,24 @@ message (but without a beep), then returns a very large number.
@print{} Arithmetic error: (arith-error)
@print{} Arithmetic error: (arith-error)
@result{} 1000000
@result{} 1000000
@end group
@end group
@end smallexample
@end example
@noindent
@noindent
The handler specifies condition name @code{arith-error} so that it will handle only division-by-zero errors. Other kinds of errors will not be handled, at least not by this @code{condition-case}. Thus,
The handler specifies condition name @code{arith-error} so that it
will handle only division-by-zero errors. Other kinds of errors will
not be handled (by this @code{condition-case}). Thus:
@smallexample
@example
@group
@group
(safe-divide nil 3)
(safe-divide nil 3)
@error{} Wrong type argument: number-or-marker-p, nil
@error{} Wrong type argument: number-or-marker-p, nil
@end group
@end group
@end smallexample
@end example
Here is a @code{condition-case} that catches all kinds of errors,
Here is a @code{condition-case} that catches all kinds of errors,
including those signaled with @code{error}:
including those from @code{error}:
@smallexample
@example
@group
@group
(setq baz 34)
(setq baz 34)
@result{} 34
@result{} 34
...
@@ -1108,7 +1108,7 @@ including those signaled with @code{error}:
...
@@ -1108,7 +1108,7 @@ including those signaled with @code{error}:
@print{} The error was: (error "Rats! The variable baz was 34, not 35")
@print{} The error was: (error "Rats! The variable baz was 34, not 35")
@result{} 2
@result{} 2
@end group
@end group
@end smallexample
@end example
@defmac ignore-errors body@dots{}
@defmac ignore-errors body@dots{}
This construct executes @var{body}, ignoring any errors that occur
This construct executes @var{body}, ignoring any errors that occur
...
@@ -1119,12 +1119,12 @@ otherwise, it returns @code{nil}.
...
@@ -1119,12 +1119,12 @@ otherwise, it returns @code{nil}.
Here's the example at the beginning of this subsection rewritten using
Here's the example at the beginning of this subsection rewritten using
@code{ignore-errors}:
@code{ignore-errors}:
@smallexample
@example
@group
@group
(ignore-errors
(ignore-errors
(delete-file filename))
(delete-file filename))
@end group
@end group
@end smallexample
@end example
@end defmac
@end defmac
@defmac with-demoted-errors body@dots{}
@defmac with-demoted-errors body@dots{}
...
@@ -1279,7 +1279,7 @@ Variables}).
...
@@ -1279,7 +1279,7 @@ Variables}).
For example, here we make an invisible buffer for temporary use, and
For example, here we make an invisible buffer for temporary use, and
make sure to kill it before finishing:
make sure to kill it before finishing:
@smallexample
@example
@group
@group
(let ((buffer (get-buffer-create " *temp*")))
(let ((buffer (get-buffer-create " *temp*")))
(with-current-buffer buffer
(with-current-buffer buffer
...
@@ -1287,7 +1287,7 @@ make sure to kill it before finishing:
...
@@ -1287,7 +1287,7 @@ make sure to kill it before finishing: