unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / 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

* Re: getting a backtrace when catching errors with condition-case - How?
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Klaus Berndl @ 2004-09-09  8:28 UTC (permalink / raw)



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: 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

* Re: getting a backtrace when catching errors with condition-case - How?
  2004-09-09  8:28 ` Klaus Berndl
@ 2004-09-09 18:47   ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2004-09-09 18:47 UTC (permalink / raw)


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

[ Somehow it was marked as utf-16be, and was displayed by my Gnus as
  one very long line of ideograms ]

> 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.

Use debug-on-signal.


        Stefan

^ 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).