On Wednesday, April 13, 2016 at 4:17:41 PM UTC-4, johnbclements wrote: > Unless I’m misreading docs and source code, there’s currently no handin > utility function that allows checking of the exception message. > > I propose adding !test/exn/msg, that accepts a regexp in addition to its > other argument, and succeeds only if the message returned in the exception > matches the given regexp. Essentially, just like rackunit’s `check-exn`, > except that no thunk is required on the `actual` arg. > > I’d be happy to submit a pull request for this, if you folks think it makes > sense. (Also, I’m open to suggestions on the ordering of the arguments.) > > Thoughts?
Unless I'm mistaken, or not reading you correctly, `with-handlers` takes predicate - handler pairs... and that predicate can be pretty much anything you want it to be. All's it needs to do is accept an exception as an argument and return #t when you want it to. So, would something like this work for your purposes? (with-handlers ([(compose (curry regexp-match? #rx"some error message substring, eh?") exn-message) (lambda (exn) (some-exn-handler-eh exn))]) (call-some-brittle-code)) What you propose is a pretty neat idea, though, but I can mash such a predicate together with trivial uses of compose, curry, conjoin, and disjoin. If I were to need to do something like that, I'd just do the composition, since it'll be more familiar with me and it fits in better with the language's idioms. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.