scheme - Get rid of uncaught exception -


i have piece of software, written in racket, want use very simple exception handler: when exception thrown, handler print out message , application terminates.

i can reproduce behaviour in following toy example:

(define (body)    (begin     (displayln "first line")     (error "some error")     (displayln "this line not printed")))  (call-with-exception-handler (lambda (x) (displayln "exception handler")) body) 

the output of code is:

first line exception handler uncaught exception: #<void> 

i want quit after displayln expression, in exception handler (i.e. expression prints "exception handler"). how can that?

try this:

(with-handlers ([exn:fail? (lambda (exn)                              ; in case need error message                              (displayln (exn-message exn))                              (displayln "exception handler"))])   (displayln "first line")   (error "some error")   (displayln "this line not printed")) 

it'll print:

first line error exception handler 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -