This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-23
Channels
- # bangalore-clj (1)
- # beginners (23)
- # boot (90)
- # cljs-dev (133)
- # cljsrn (5)
- # clojure (104)
- # clojure-austin (1)
- # clojure-belgium (2)
- # clojure-dev (12)
- # clojure-gamedev (4)
- # clojure-italy (2)
- # clojure-russia (6)
- # clojure-spec (30)
- # clojure-uk (117)
- # clojurescript (197)
- # core-async (25)
- # cursive (9)
- # datomic (95)
- # devops (1)
- # dirac (49)
- # emacs (1)
- # hoplon (3)
- # immutant (10)
- # lein-figwheel (2)
- # luminus (5)
- # off-topic (43)
- # pedestal (1)
- # protorepl (1)
- # re-frame (13)
- # sql (5)
- # untangled (1)
given a spec (obtained from ex-data of an exception thrown by inspect, i.e the :cljs.spec.alpha/spec), how can one obtain the key of that spec in the registry?
My current solution is to parse it out of the exception message, which contains “Call to #‘name-of-var did not conform to spec…“. It would be nice if instrument included the key in the ex-data, but I might be misunderstanding something here.
@odinodin can you give please show the data you are trying to go from -> to?
I think you might want to use (s/form)
or (s/get-spec)
, but I'm not sure yet what you are trying to get
@wilkerlucio it is a spec record object, as provided by the exception thrown by instrument when a fdef’ed function is called with non-conforming input.
it is the spec object that (s/get-spec 'the-fdefed-var)
would return as far as I can tell
that's a long chain, hehe, I'm not sure what kind of data you are looking at, can you paste what your (ex-data)
result looks like?
This is what (ex-data) returns:
{:cljs.spec.alpha/problems ({:some-description-of-the-problem "..."})
:cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha56508],
:cljs.spec.alpha/value ({:foo "bar"}),
:cljs.spec.alpha/args ({:foo "bar"})
:cljs.spec.alpha/failure :instrument}
or it would probably be more correct to say, what key points to this spec in the registry
@odinodin gotcha, you can try calling (s/form)
and (s/get-spec)
on it, but I'm not sure if will work
@wilkerlucio (s/form)
only returns the spec as defined on the (s/fdef)
var. I’ll just parse the var out from the error message instead. Anyway, thanks for your suggestions 🙂
no problem, I'm glad you can at least work around it, maybe other people will have a better solution 😉
@odinodin there is a ticket filed for this at https://dev.clojure.org/jira/browse/CLJ-2166 - patches welcome
I just haven’t had time to look at it yet
@alexmiller nice! Just what I was looking for :)
does anyone know of a library to convert clojure.spec problem explanations to more human-readable output?
https://github.com/bhauman/strictly-specking seems to have some work in this direction, but I don’t think it’s a drop-in solution right now
I’m a bit confused by the value of “in” when using “map-of” https://gist.github.com/bhb/6f06dd07bcf5b275a7d4faf3167bfc85
I searched JIRA but could not find an issue, so it may be a misunderstanding on my part
@samueldev ^-- (sorry, forgot to mention you, see my comment above)
@samueldev I think @ericnormand is also maybe working on something for more human-readable error messages?
thanks @bbrinck ! I'll do some digging with @ericnormand's work and bruces!
I think also the above odinodin is working on something for re-frame