Add map as catch-data predicate
I've found myself wanting to catch based on values of domain specific keys in the exception data. You could do #(= :some-key (:some-value %)) as the predicate, but that seemed to get a bit repetitive. This use case, or the implementation, might not make sense to add, but just thought I'd propose it.
I definitely appreciate the need, and I'd like to have some way of doing this. I'm a bit hesitant about map literals because they are technically functions so they would currently act as a predicate in that respect. I doubt backwards compatibility would be a real issue but confusing semantics might be.
Another option is a different clause name, but I don't know of a good one (catch-data-matching-map? :disappointed:)
I'll be giving this some thought. Thanks for the PR.
Yeah, that all makes sense. I'd be happy to make some changes if you decide on a preferred way of doing something similar.
Another idea: if you had a helper function that let you do (map-kv-pred :some-key :some-value), would that address most of your concerns? It's not as succinct as a map but there's at least fewer elements in the code, less nesting, etc.
If you do like that idea, the question would be if it belongs in this library (it's not directly related to exceptions, but seems unlikely to be too useful elsewhere), and if so what to call it.
I like that idea. I called it sub-data. It could definitely be part of another library, or just implemented wherever it's needed - given that it's pretty simple - if you don't think it belongs here.