We're updating the issue view to help you get more done. 

[spec] instrument exception doesn't contain function name in ex-data

Description

When an instrumented function fails, it throws an IExceptionInfo. The ex-data of this exception contains the arguments that failed, but not the function that was called.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (require '[clojure.spec.alpha :as s] '[clojure.spec.test.alpha :as stest]) (defn foo [x] (+ x 1)) (s/fdef foo :args (s/cat :x number?)) (stest/instrument `foo) (foo "x") ;; ExceptionInfo Call to #'user/foo did not conform to spec: (ex-data *e) {:clojure.spec.alpha/problems [{:path [:args :x], :pred number?, :val "x", :via [], :in [0]}], :clojure.spec.alpha/args ("x"), :clojure.spec.alpha/failure :instrument, :clojure.spec.test.alpha/caller {:file "form-init1493151512736136730.clj", :line 101, :var-scope user/eval23284}}

*Proposed: Add an extra key clojure.spec.alpha/fn that has the symbol of the var under instrumentation.

After:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 user> (ex-data *e) => {:clojure.spec.alpha/problems [{:path [:args :x], :pred clojure.core/number?, :val "x", :via [], :in [0]}], :clojure.spec.alpha/spec #object[clojure.spec.alpha$regex_spec_impl$reify__1210 0x4db4a004 "clojure.spec.alpha$regex_spec_impl$reify__1210@4db4a004"], :clojure.spec.alpha/value ("x"), :clojure.spec.alpha/fn user/foo, :clojure.spec.alpha/args ("x"), :clojure.spec.alpha/failure :instrument, :clojure.spec.test.alpha/caller {:file "form-init2105027941758372775.clj", :line 1, :var-scope user/eval1050}}

Patch: clj2166.patch

Screened by: Alex Miller

Environment

None

Status

Assignee

Unassigned

Reporter

import

Labels

Approval

Ok

Patch

Code

Fix versions

Affects versions

Release 1.9

Priority

Minor