[racket] Handling errors from in-directory - and handling errors more generally
5 hours ago, Matthew Flatt wrote:
> At Wed, 13 Oct 2010 20:48:05 -0400, Eli Barzilay wrote:
> > I'm getting an escape one:
> >
> > -> (let ([cont? #t])
> > (with-handlers ([exn:break?
> > (lambda (e)
> > (when cont?
> > (printf "BREAK! --> jump back to ~s\n"
> > (exn:break-continuation e))
> > (set! cont? #f)
> > ((exn:break-continuation e))))])
> > (for ([i (in-naturals)]) (displayln i) (sleep 0.5))))
> > 0
> > 1
> > BREAK! --> jump back to #<escape-continuation>
> > continuation application: attempt to jump into an escape continuation
>
> To successfully resume, you have have to use the lower-level
> `call-with-exception-handler' layer instead of `with-handlers'.
I first thought that this means that I need to use
`call-with-exception-handler' to reraise a new break exception with
the continuation -- something like this:
(call-with-exception-handler
(lambda (e)
(if (exn:break? e)
(let/cc k
(make-exn:break (exn-message e)
(exn-continuation-marks e)
k))
e))
(lambda () ...))
but this barfs with:
exn:break: expected argument of type <escape continuation>; given
#<continuation>
Maybe it will help to have some example code that uses the
continuation field?
(Background: I saw the mention of `exn:break' having a continuation
while hacking the interactive.rkt thing -- and thought that it would
be nice to add a new ",cont" command that continues an aborted
computation. But so far it seems impossible to do, probably
intentionally, so I wonder how it can be used.)
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!