[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Exceptions via port
I'm not sure if this would work for your problem at large, but one
approximation would be to extract the `message' field of the exception
and just send that over the port. Then, on the other end, call `error'
with that string (or even construct
If you want to propogate more info, you can use struct->vector to
transmit the exn record:
> (define e (with-handlers ([(lambda (x) #t) (lambda (x) x)]) (car 1)))
> (struct->vector e)
(vector
'struct:exn:application:type
"car: expects argument of type <pair>; given 1"
#<continuation-mark-set>
1
'pair)
Then, on the other side, you will need to go from the tag to the maker
to reconstruct the exception;
Beware -- the continuation-mark-set is not marshallable, but since you
are transmitting the value over a port, chances are the other end
couldn't have used it anyway. For most uses, you can just replace that
field with #f.
Robby
Quoting Manuel Giraud:
>
> I'm trying to read an exception on a port to raise it: (raise (read
> port)). But since exception are struct, read can't help. Maybe, I can
> store an exception in a more read-friendly structure, but I can't
> figure out how to construct back the exception. Any idea?
>
> --
> Donny: Are these the Nazis, Walter?
> Walter: No, Donny, these men are nihilists. There's nothing to be
> afraid of.
>
> _Manuel Giraud_