Copyright (C) 2000-2012 |
GNU Info (librep.info)ErrorsErrors ...... Errors are a type of non-local exit; when a form can not be evaluated for some reason an error is normally "signalled". If an error-handler has been installed for that type of error, control is passed to the handler for that error, and evaluation continues. If there is no suitable handler, control is passed back to the innermost input loop and a suitable error message is printed. - Function: signal error-symbol data Signals that an error has happened. ERROR-SYMBOL is a symbol classifying the type of error, it should have a property `error-message' (a string) which is the error message to be printed. DATA is a list of objects which are relevant to the error -- they will be made available to any error-handler or printed with the error message otherwise. (signal 'void-value '(some-symbol)) error--> Value as variable is void: some-symbol - Variable: debug-on-error This variable is consulted by the function `signal'. If its value is either `t' or a list containing the ERROR-SYMBOL to `signal' as one of its elements, the Lisp debugger is entered. When the debugger exits the error is signalled as normal. - Variable: backtrace-on-error Similar to `debug-on-error', but if an error is matched, the current backtrace is printed to the standard error stream, and control continues. When you expect an error to occur and need to be able to regain control afterwards the `condition-case' special form may be used. - Macro: condition-case symbol body-form error-handlers... `condition-case' evaluates the BODY-FORM with the ERROR-HANDLERS in place. If an error occurs and one of the handles matches the error, then it is evaluated with the value of SYMBOL set to the error information. Each of the ERROR-HANDLERS is a list whose car is a symbol defining the type of error which this handler catches. The cdr of the list is a list of forms to be evaluated in a `progn' if the handler is invoked. While the forms of the error handler are being evaluated the variable SYMBOL is bound to the value `(ERROR-SYMBOL . DATA)' (these were the arguments to the `signal' form which caused the error). If SYMBOL is the symbol `nil' (or the empty list `()'), then the error information is not available to the handler. The special value, the symbol `error', in the car of one of the ERROR-HANDLERS will catch _all_ types of errors. (condition-case data (signal 'file-error '("File not found" "/tmp/foo")) (file-error data) (error (setq x z))) ;Default handler => (file-error "File not found" "/tmp/foo") automatically generated by info2www version 1.2.2.9 |