From: Marius Vollmer <mvo@zagadka.ping.de>
Subject: Re: reporting 'system-error informatively
Date: 20 Oct 2002 23:38:13 +0200 [thread overview]
Message-ID: <87r8ekx03e.fsf@zagadka.ping.de> (raw)
In-Reply-To: <m38z0unn4f.fsf@multivac.cwru.edu>
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
next prev parent reply other threads:[~2002-10-20 21:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-19 21:18 reporting 'system-error informatively Paul Jarc
2002-10-20 21:38 ` Marius Vollmer [this message]
2002-10-20 23:02 ` Daniel Skarda
2002-10-21 14:46 ` Marius Vollmer
2002-10-21 6:13 ` Paul Jarc
2002-10-21 14:45 ` Marius Vollmer
2002-10-21 18:36 ` Paul Jarc
2002-10-21 18:55 ` Neil Jerram
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r8ekx03e.fsf@zagadka.ping.de \
--to=mvo@zagadka.ping.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).