On Wed, May 25, 2016 at 6:38 AM, Alex Miller <a...@puredanger.com> wrote:
> So something like > > (defn valid-or-explain [spec data] > (let [v (s/valid? spec data)] > (when-not v (s/explain spec data)) > v)) > > Right, that's what I was originally thinking. The form Sean Corfield suggested might make more sense: (defn assert-valid [spec data] (when-not (s/valid? spec data) (throw (AssertionError. (with-out-str (s/explain spec data)) (ex-info “SpecFailure” (s/explain-data spec data)))))) My objective in suggesting it is that we figure out what is the most useful thing inside a pre-/post-condition, and implement it once and standardize on it rather than a bunch of people coming up with their own ad-hoc solution in their own libraries for printing a meaningful error message when something doesn't conform. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.