guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting scheme error informations when running scheme code from C


From: Christian Mauduit
Subject: Re: Getting scheme error informations when running scheme code from C
Date: Sun, 11 Sep 2005 22:19:30 +0200
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050803)

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 <address@hidden>     __/\__ ___
                                        \~/ ~/(`_ \   ___
http://www.ufoot.org/                   /_o _\   \ \_/ _ \_
http://www.ufoot.org/gnupg.pub            \/      \___/ \__)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]