diff options
author | Karl Heuer <kwzh@gnu.org> | 1996-07-17 04:54:04 +0000 |
---|---|---|
committer | Karl Heuer <kwzh@gnu.org> | 1996-07-17 04:54:04 +0000 |
commit | 840797eed72533d2a46de3e808eb58609cdf4cf1 (patch) | |
tree | 14decba5f7956280faf3661f9d62909b44f39844 /lispref/control.texi | |
parent | 496110ef79d9e24767214dea03811097c69d7f65 (diff) | |
download | emacs-840797eed72533d2a46de3e808eb58609cdf4cf1.tar.gz |
Changes for Emacs 19.32.
Diffstat (limited to 'lispref/control.texi')
-rw-r--r-- | lispref/control.texi | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lispref/control.texi b/lispref/control.texi index c7367894919..1a5e7033c1c 100644 --- a/lispref/control.texi +++ b/lispref/control.texi @@ -878,23 +878,31 @@ After executing the body of the handler, the @code{condition-case} returns normally, using the value of the last form in the handler body as the overall value. +@cindex error description The argument @var{var} is a variable. @code{condition-case} does not bind this variable when executing the @var{protected-form}, only when it -handles an error. At that time, it binds @var{var} locally to a list of -the form @code{(@var{error-symbol} . @var{data})}, giving the -particulars of the error. The handler can refer to this list to decide -what to do. For example, if the error is for failure opening a file, -the file name is the second element of @var{data}---the third element of -@var{var}. +handles an error. At that time, it binds @var{var} locally to an +@dfn{error description}, which is a list giving the particulars of the +error. The error description has the form @code{(@var{error-symbol} +. @var{data})}. The handler can refer to this list to decide what to +do. For example, if the error is for failure opening a file, the file +name is the second element of @var{data}---the third element of the +error description. If @var{var} is @code{nil}, that means no variable is bound. Then the error symbol and associated data are not available to the handler. @end defspec +@defun error-message-string error-description +This function returns the error message string for a given error +descriptor. It is useful if you want to handle an error by printing the +usual error message for that error. +@end defun + @cindex @code{arith-error} example Here is an example of using @code{condition-case} to handle the error -that results from dividing by zero. The handler prints out a warning -message and returns a very large number. +that results from dividing by zero. The handler displays the error +message (but without a beep), then returns a very large number. @smallexample @group @@ -904,7 +912,8 @@ message and returns a very large number. (/ dividend divisor) ;; @r{The handler.} (arith-error ; @r{Condition.} - (princ (format "Arithmetic error: %s" err)) + ;; @r{Display the usual message for this error.} + (message "%s" (error-message-string err)) 1000000))) @result{} safe-divide @end group |