all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* getting a backtrace when catching errors with condition-case - How?
@ 2004-09-09  8:12 Klaus Berndl
  2004-09-09  8:28 ` Klaus Berndl
  0 siblings, 1 reply; 3+ messages in thread
From: Klaus Berndl @ 2004-09-09  8:12 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-16be, Size: 2889 bytes --]


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

,----
|   backtrace()
|   byte-code("þÿ
|   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: klaus.berndl@sdm.de
sd&m AG				http://www.sdm.de
software design & management	
Carl-Wery-Str. 42, 81739 Muenchen, Germany
Tel +49 89 63812-392, Fax -220

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-09-09 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-09  8:12 getting a backtrace when catching errors with condition-case - How? Klaus Berndl
2004-09-09  8:28 ` Klaus Berndl
2004-09-09 18:47   ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.