Today I hit a problem with some trivial code I wrote using Coops that I just
couldn't figure out. The relevant code is here:

http://paste.call-cc.org/paste?id=d09b2c1438a7f063c07cd089fb3e74c68d0b2804

Yeah, I forgot to add the "port" argument. In any case, Coops' error message
is misleading:

#<no print-method defined for: #<coops instance of `<color>'>>

There is a method alright, it's just crashing :)

Now, This is how coops handles the situation:

(define-record-printer (coops-instance obj out)
>   (handle-exceptions ex
>                      (begin
>                        (display "#<no print-method defined for: " out)
>                        (default-print-method obj out)
>                        (display ">" out))
>                      (print-object obj out) ) )


It will display the same error message regardless of the condition. So let's
modify it to see what it was:

(define-record-printer (coops-instance obj out)
>   (handle-exceptions ex
>                      (begin
>                        (display ((condition-property-accessor 'exn
> 'message)))
>                       ; (display "#<no print-method defined for: " out)
>                        (default-print-method obj out)
>                        (display ">" out))
>                      (print-object obj out) ) )


The actual error is thus:  #<Error in printer of record type
`coops-instance': bad argument count - received 0 but expected 1>
which is an (exn arity), in my code.

As pointed out by sjaaman, it should only catch the dispatch error. I could
create a patch to do that, but I am not confortable enough with coops' code
at this point and I am sure the error handling could be improved in ways I
can't even see yet..


Also, there are no flaming koalas.



-- Stephen

*"Kids these days.*
*Whatever happened to hard work?*

       -- Joel Spolsky, The perils of javaschools"
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to