clojure.spec already does this by communicating the path where the failure occurred. Also if you use s/cat you can label the arguments which I think is probably more friendly and you'll still get the path.
(require '[cljs.spec :as s]) (defn foo [a b c] (+ a b c)) (s/fdef foo :args (s/cat :a number? :b number? :c number?)) (s/instrument #'foo) (foo 1 2 :bar) ;; Error: Call to #'cljs.user/foo did not conform to spec: ;; In: [2] val: :bar fails at: [:args :c] predicate: number? ;; :cljs.spec/args (1 2 :bar) On Thu, Jun 23, 2016 at 11:41 AM, Elena Machkasova <ele...@morris.umn.edu> wrote: > I am trying to use a combination of fdef and instrument in spec, and I was > wondering if there is a way to apply a condition to each of the :args and > be able to report the argument number on which the precondition fails. For > instance, we require all args (in a function with a variable number of > arguments) to be numbers, and get the message that says that the third > argument has failed this condition. > > Thanks! > > Elena > > > -- > 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. > -- 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.