From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Klaus Berndl Newsgroups: gmane.emacs.help Subject: Re: getting a backtrace when catching errors with condition-case - How? Date: 09 Sep 2004 10:28:37 +0200 Organization: "sd&m AG, Muenchen, Germany" Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1094718902 30267 80.91.224.253 (9 Sep 2004 08:35:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 9 Sep 2004 08:35:02 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 09 10:34:54 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1C5KOM-0002aB-00 for ; Thu, 09 Sep 2004 10:34:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C5KTg-0001s8-18 for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Sep 2004 04:40:24 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer00.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!emea.uu.net!news.sdm.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 106 Original-NNTP-Posting-Host: sachrang.muc.sdm.de Original-X-Trace: news.sdm.de 1094718511 21888 193.102.182.8 (9 Sep 2004 08:28:31 GMT) Original-X-Complaints-To: usenet@news.sdm.de Original-NNTP-Posting-Date: Thu, 9 Sep 2004 08:28:31 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Original-Xref: shelby.stanford.edu gnu.emacs.help:125192 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:20547 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:20547 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