[CM] s7: bubbling up errors (bug?)

Christos Vagias chris.actondev at gmail.com
Sat Jul 18 13:46:04 PDT 2020


Oh, I see!
Thanks a lot for the clarification (and thorough explanation).

I saw this line from the documentation

(apply throw args))))) ;   and pass the error on up

and didn't take into account the signature of throw.

Thanks again!

On Sat, 18 Jul 2020 at 22:01, <bil at ccrma.stanford.edu> wrote:

> throw is (throw tag . info), that is it takes its trailing args and puts
> them
> in a list.  The first throw gets the args: 'some-error "..." 1.  It
> passes
> these as: 'some-error ("..." 1) to the first error handler (that's why
> you
> can apply format to cadr -- cadr has been turned into a list).  You
> throw
> that again using apply, so its args the second time are: some-error
> '("..." 1),
> (I'm trying to show that the second call is not like the first -- it has
> only one trailing arg, the list '("..." 1).  Once again throw treats it
> as
> a rest arg, and puts it in a list, then the second error handler sees:
> some-error (("..." 1)).  If you want to rethrow, the second throw needs
> to match the first one, use (apply throw (car args) (cadr args)).
> It might be better to use (lambda (type info) for the error handler,
> so you can say
>
> (catch #t
>    (lambda ()
>      (catch #t
>        (lambda ()
>         (throw 'some-error "::: ERROR ::: (~A)~%" 1))
>        (lambda (type info)
>         (apply format *stderr* info)
>         (apply throw type info))))
>    (lambda (type info)
>      (apply format *stderr* info)
>      ))
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/mailman/private/cmdist/attachments/20200718/12495346/attachment.html>


More information about the Cmdist mailing list