If I use Slingshot’s try+ and catch, it’s easy to write a selector to match on the contents of a map:
(defn dosomething (throw+ {:some :data}))
(try+ (dosomething)
(catch [:some :data] ;; recover))
However, if I want to use ex-info, that catch selector doesn’t match the ExceptionInfo‘s data:
(defn dosomething (throw (ex-info "A message" {:some :data})))
Obviously I can catch an ExceptionInfo or write a custom predicate to match the data, I was just wondering if I was missing something about Slingshot or ex-info, as I’d been led to believe they worked together more smoothly than this.
I’m not really sure why you want to throw an ExceptionInfo, my understanding is it’s just a carrier for arbitrary data that you can just throw normally with throw+.
Or if the point is that you don’t want to use throw+, then I don’t think there is a totally straightforward way to catch it. You’d have to do something like
I don’t know what the use case is for wanting to use try+ but not throw+.