From ... From: Erik Naggum Subject: Re: catching floating point exceptions in lisp Date: 1997/10/10 Message-ID: <3085446108962378@naggum.no>#1/1 X-Deja-AN: 279114950 References: <343D4E78.5731@ics.uci.edu> mail-copies-to: never Organization: Naggum Software; +47 8800 8879; http://www.naggum.no Newsgroups: comp.lang.lisp * Stephen Dongjun Bay | Occaisonally divide by zero errors occur and stops program execution. | Instead of stoping my lisp program I would like to handle the divide by | zero errors automatically (i.e. I can throw away the expressions because | they are invalid) and continue. if the expression is truly uninteresting when it contains such an error, you can wrap the call to `eval' in an `ignore-errors' form. the primary value is then nil if an error occurred. you may check the secondary value for any condition that might have occurred. otherwise, you might want to consider setting up a handler for the condition `arithmetic-error'. you also gain access to the operands and the operation that caused this condition. (handler-case (+ (/ 3 4) (/ 1 0)) (arithmetic-error (x) (format t "~S bit the proverbial bullet" (cons (arithmetic-error-operation x) (arithmetic-error-operands x))))) -| (/ 1 0) bit the proverbial bullet => nil #\Erik -- if you think this year is "97", _you_ are not "year 2000 compliant". see http://www.naggum.no/emacs/ for Emacs-20-related material.