Re: [racket] Dirt-simple exceptions

2010-09-05 Thread Mark Carter
- Original Message > From: Robby Findler > (with-handlers ([exn:fail? (lambda (exn) put-specified-default-here)]) > try-something-here) That's the fellow! Here's a little convenience macro I defined: (define-syntax catch-errors (syntax-rules () ((catch-all error-v

Re: [racket] Dirt-simple exceptions

2010-09-05 Thread Robby Findler
I think you want with-handlers. (with-handlers ([exn:fail? (lambda (exn) put-specified-default-here)]) try-something-here) Robby On Sun, Sep 5, 2010 at 7:36 AM, Mark Carter wrote: > I can't get my head around Racket's exception mechanism. I want to say "try > something, and if it fails, retu

[racket] Dirt-simple exceptions

2010-09-05 Thread Mark Carter
I can't get my head around Racket's exception mechanism. I want to say "try something, and if it fails, return a specified default value". This returns the expected result: (with-exception-handler (lambda (x) "Oops") (/ 1 0)) because it returns "Oops". However, if I type (with-exception-han