From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Christian Mauduit Newsgroups: gmane.lisp.guile.user Subject: Re: Getting scheme error informations when running scheme code from C Date: Sun, 11 Sep 2005 22:19:30 +0200 Message-ID: <43249152.30103@ufoot.org> References: <4322DE2C.60801@ufoot.org> <4322EEBA.1090202@mail.msen.com> <432351D1.8010102@ufoot.org> <43236EF9.5050400@mail.msen.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1126470943 11730 80.91.229.2 (11 Sep 2005 20:35:43 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 11 Sep 2005 20:35:43 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Sep 11 22:35:39 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EEYXD-0002L7-QD for guile-user@m.gmane.org; Sun, 11 Sep 2005 22:34:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EEYXD-0002kk-8m for guile-user@m.gmane.org; Sun, 11 Sep 2005 16:34:43 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EEYVU-0001Zh-Sq for guile-user@gnu.org; Sun, 11 Sep 2005 16:32:57 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EEYVQ-0001YD-I8 for guile-user@gnu.org; Sun, 11 Sep 2005 16:32:54 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EEYV5-0000zy-7p for guile-user@gnu.org; Sun, 11 Sep 2005 16:32:31 -0400 Original-Received: from [212.27.42.30] (helo=smtp4-g19.free.fr) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EEYEk-0005DU-EF for guile-user@gnu.org; Sun, 11 Sep 2005 16:15:38 -0400 Original-Received: from moulin (arl95-1-82-232-241-64.fbx.proxad.net [82.232.241.64]) by smtp4-g19.free.fr (Postfix) with ESMTP id D69B328356 for ; Sun, 11 Sep 2005 22:15:08 +0200 (CEST) Original-Received: from guenegaud.streets ([192.168.0.4]) by moulin with esmtp (Exim 4.50) id 1EEYEE-0008DI-FV for guile-user@gnu.org; Sun, 11 Sep 2005 22:15:07 +0200 User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050803) X-Accept-Language: fr, en Original-To: guile-user@gnu.org In-Reply-To: <43236EF9.5050400@mail.msen.com> X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:4737 Archived-At: Hi, > If we assume that the catch'ing lambda is always the same, then the > stack-frames related to it should be stable. So, you should be able to > discard the bottom n frames every time: > > For example: > (lazy-catch #t > (lambda () (+ 1 (hubert))) > (lambda (key . args) > (let ((s (make-stack #t))) > (display (list key args)) > (newline) > (display-backtrace s (current-output-port) > (- (stack-length s) 1) > (- (stack-length s) 3))) > (newline) > (display "throw on") (newline) > (throw 'bob))) Thanks, this helped a lot! > I had already decoded the frame for my own purposes (a logging > function), so here's the code above plus it outputs the decoded frame > info (I don't claim this is bullet proof!): > (lazy-catch #t > (lambda () (+ 1 (hubert))) > (lambda (key . args) > (let* ( > (s (make-stack #t)) > (bottom-frames-to-trim 3) > (frame-of-interest > (stack-ref s > bottom-frames-to-trim)) > (source-me (frame-source frame-of-interest)) > (fname (and source-me (source-property source-me 'filename))) > (procedure (frame-procedure (frame-of-interest)) > (source-line (and source-me (1+ (source-property source-me > 'line)))) > ) > > (display (list key args)) FYI I use the following code instead, to display args: (apply format (cons #f (cons (cadr args) (caddr args)))) Unelegant in the source, but displays things in a nicer way IMHO. Have a nice day, Christian, problem fixed, happy coder 8-) -- Christian Mauduit __/\__ ___ \~/ ~/(`_ \ ___ http://www.ufoot.org/ /_o _\ \ \_/ _ \_ http://www.ufoot.org/gnupg.pub \/ \___/ \__) _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user