Quoting William Conrad Halliburton ([EMAIL PROTECTED]):
> 2. Using ignore-errors around multiple lisp processes. On error I output

Around multiple lisp processes?

> the error message to a log file. I wish to also output a backtrace. How
> can I print a backtrace from the returned condition?

Try something along these lines:

(defmacro my-ignore-errors (() &body body)                                      
  "Like IGNORE-ERRORS, but in case of failure, return backtrace string as       
   third value."                                                                
  `(block %debug-escape                                                        
     (handler-bind                                                             
         ((error (lambda (c)                                                   
                   (let ((backtrace                                            
                          (with-output-to-string (*debug-io*)                  
                            (debug:backtrace))))                               
                     (return-from %debug-escape                                
                       (values nil c backtrace))))))                           
       ,@body)))

(As a bit of unsolicited advice, specific handlers are normally
preferred over IGNORE-ERRORS, but for logging in servers a `catch-all'
error handler can make sense.  However, macros like this one should
normally check for a global variable at run-time, thus allowing the user
to turn error handling off while debugging without having to
re-compile.)

Reply via email to