help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting a backtrace when catching errors with condition-case - How?


From: Klaus Berndl
Subject: Re: getting a backtrace when catching errors with condition-case - How?
Date: 09 Sep 2004 10:28:37 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Sorry, seems that i have posted the first message including control
characters, so here i again:

Hi,

please see the following short code (a simplified excerpt of the ECB setup)

,----
| (defun ecb-clean-up-after-activation-failure (msg err)
|   "Complete cleanup of all ECB-setups and report an error with message MSG."
|   (let ((ecb-minor-mode t))
|     (ecb-deactivate-internal t)
|     (if ecb-running-xemacs
|         (redraw-modeline t)
|       (force-mode-line-update t))
|     (error "ECB %s: %s (error-type: %S, error-data: %S)" ecb-version msg
|            (car err) (cdr err))))
| 
| (defun ecb-set-something-up ()
|   (function-1)
|   (function-2))
| 
| (defun ecb-activate ()
|   ;; step 1
|   (condition-case err-obj
|       ;; run personal hooks before drawing the layout
|       (ecb-set-something-up)
|     (error
|      ;; (backtrace) ####
|      (ecb-clean-up-after-activation-failure
|       "Errors during the basic setup of ECB."
|       err-obj)))
| 
|   ;; step 2
|   (condition-case err-obj
|       ;; run personal hooks before drawing the layout
|       (ecb-set-something-more-up)
|     (error
|      (ecb-clean-up-after-activation-failure
|       "Errors during the hooks of ecb-activate-before-layout-draw-hook."
|       err-obj)))
| 
|   ;; step 3
| 
|   ;; step 4
| 
|   ;; ...
|   )
`----

This code enables a save setup of ECB... because in case of an error it does a
full cleanup all of setup-steps before this error (e.g. deactivating already
activated advices etc...).

it works fine but has one drawback: In case of an error i get the error-type
(e.g. wrong-argument-type-p) and the error-data reported (see
ecb-clean-up-after-activation-failure) but no backtrace so i can see where the
error really occurs.

example:
Suppose that in the function ecb-set-something-up occurs an error but this
error occurs in fact deep inside of `function-1' - means in any function
called by `function-1'. Then i get no backtrace about this call-hierarchy even
if i add `backtrace' to the error-handler (before
`ecb-clean-up-after-activation-failure' is called - line is marked above with
####). Binding `stack-trace-on-error' to t during the whole setup doesn't help
####too :-(

The only stuff i get is that message

,----
| ecb-clean-up-after-activation-failure: ECB 2.28: Errors during the
| basic setup of ECB. (error-type: error, error-data: ("blblbla"))
`----


which is what i want and the backtrace (when i bind `stack-trace-on-error' to
t during the `ecb-activate':

,----
|   signal(error ("ECB 2.28: Errors during the basic setup of ECB. (error-type: 
error, error-data: (\"blablabla\"))"))
|   error("ECB %s: %s (error-type: %S, error-data: %S)" "2.28" "Errors during 
the basic setup of ECB." error ("blablabla"))
|   ecb-clean-up-after-activation-failure("Errors during the basic setup of 
ECB." (error "blablabla"))
|   ecb-activate--impl()
|   ecb-activate-internal()
|   ecb-minor-mode(1)
|   ecb-activate()
`----


which is nothing which can help me to identify the real location of the error
:-(

Any hints how i can combine (catching errors and then doing a cleanup and
getting in addition a helpful backtrace?

Thanks a lot in advance!
Klaus

--
Klaus Berndl                    mailto: address@hidden
sd&m AG                         http://www.sdm.de
software design & management    
Carl-Wery-Str. 42, 81739 Muenchen, Germany
Tel +49 89 63812-392, Fax -220


reply via email to

[Prev in Thread] Current Thread [Next in Thread]