From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Marius Vollmer Newsgroups: gmane.lisp.guile.user Subject: Re: reporting 'system-error informatively Date: 20 Oct 2002 23:38:13 +0200 Sender: guile-user-admin@gnu.org Message-ID: <87r8ekx03e.fsf@zagadka.ping.de> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035150033 22439 80.91.224.249 (20 Oct 2002 21:40:33 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 21:40:33 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 183NoF-0005pW-00 for ; Sun, 20 Oct 2002 23:40:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 183NnB-0004oc-00; Sun, 20 Oct 2002 17:39:25 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 183Nm2-00022R-00 for guile-user@gnu.org; Sun, 20 Oct 2002 17:38:14 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 183Nm0-00022E-00 for guile-user@gnu.org; Sun, 20 Oct 2002 17:38:13 -0400 Original-Received: from mail.dokom.net ([195.253.8.218]) by monty-python.gnu.org with esmtp (Exim 4.10) id 183Nm0-000229-00 for guile-user@gnu.org; Sun, 20 Oct 2002 17:38:12 -0400 Original-Received: from dialin.speedway42.dip103.dokom.de ([195.138.42.103] helo=zagadka.ping.de ident=qmailr) by mail.dokom.net with smtp (Exim 3.32 #2) id 183NmX-0000Oq-00 for guile-user@gnu.org; Sun, 20 Oct 2002 23:38:45 +0200 Original-Received: (qmail 5705 invoked by uid 1000); 20 Oct 2002 21:38:13 -0000 Original-To: guile-user@gnu.org In-Reply-To: Original-Lines: 54 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Errors-To: guile-user-admin@gnu.org X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.user:1239 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1239 prj@po.cwru.edu (Paul Jarc) writes: > If I catch 'system-error and display an error message, I'd like to > include the arguments of the procedure that failed along with the > procedure name and errno string. Is there a way to get the arguments > programmatically, other than by parsing the output of (backtrace)? The arguments are passed among the arguments received by the handler. You can do something like (define (call-with-error-catching thunk) (let ((the-last-stack #f) (stack-saved? #f)) (define (handle-error key args) (let ((text (call-with-output-string (lambda (cep) (if the-last-stack (display-backtrace the-last-stack cep) (display "no backtrace available.\n" cep)) (apply display-error the-last-stack cep args))))) ;;; you probably need to do something else with the text. (gtk-show-error text) #f)) (define (save-stack) (cond (stack-saved?) ((not (memq 'debug (debug-options-interface))) (set! the-last-stack #f) (set! stack-saved? #t)) (else (set! the-last-stack (make-stack #t lazy-dispatch 4)) (set! stack-saved? #t)))) (define (lazy-dispatch key . args) (save-stack) (apply throw key args)) (start-stack #t (catch #t (lambda () (lazy-catch #t thunk lazy-dispatch)) (lambda (key . args) (if (= (length args) 4) (handle-error key args) (apply throw key args))))))) which is probably way too complicated. This is a weak spot of Guile, I'm afraid. -- GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405 _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user