Re: [gtk-list] guile-gtk errors
- From: Sascha Ziemann <szi aibon ping de>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] guile-gtk errors
- Date: Thu, 15 Jan 1998 22:41:41 +0100
Seth Alves wrote:
>
> I'm using guile-gtk. Is there a way to get full backtrace info when
> an error occurs from inside a gtk callback? I see things like
>
> gtk: Wrong type argument in position 2: #f
>
> on stderr, and it can be difficult to track down.
This code from Marius helps a bit:
(define (gtk-signal-connect* widget signal callback)
(gtk-signal-connect widget signal
(lambda (. args)
(with-error-catching (apply callback args)))))
(define (call-with-error-catching thunk . opt-label)
(let ((label (and (pair? opt-label) (car opt-label)))
(the-last-stack #f)
(stack-saved? #f))
(define (handle-error key args)
(let ((cep (current-error-port)))
(if label (begin
(display label cep)
(newline 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)
(force-output cep)
(throw 'abort key)))
(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)))))))
(define-macro (with-error-catching . body)
`(call-with-error-catching (lambda () ,@body)))
-- http://www.ping.de/sites/aibon/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]