Fork me on GitHub
#clojure-spec
<
2019-06-06
>
Alex Miller (Clojure team)15:06:37

you're just getting the spammed ex-info data there, not a crafted message

Alex Miller (Clojure team)15:06:45

which clojure version and where are you seeing this?

Alex Miller (Clojure team)15:06:25

seeing it in repl (if so, which repl) or from lein command or other command?

sveri09:06:31

Getting back to this problem. I did some digging and it turns out, if I run this function as part of a web request it gets wrapped into a exception clojure.lang.ExceptionInfo and printed out like seen above vs calling the function from the repl and seeing the more readable output. What would be the idiomatic way to use spec in this environment? I could catch the exception, and display some better error? Is it possible to extract a more readable error from the exception? Two things that bug me here. 1. ExceptionInfo seems like a very generic exception and I would have to look into it to check if its a exception regarding spec. 2. I would have to do this for every function that accepts / returns a web request while I would like to have it printed readable everytime, without having to do manual exception handling, if possible.

sveri15:06:48

I see this in the cursive REPL when running a function of mine that I specced. There is also a lengthy stacktrace available and what fails is clojure.spec.test.alpha$spec_checking_fn$conform_BANG___3024.invoke Clojure version is 1.10.1 and spec is spec.alpha 0.2.176

Alex Miller (Clojure team)16:06:19

what kind of repl in Cursive?

Alex Miller (Clojure team)16:06:18

I'm most likely going to suggest you ask in #cursive as its really dependent on who is controlling the printing, which here is either cursive or nrepl

Alex Miller (Clojure team)16:06:05

that is, if you used lein or clj in this same scenario, I think you would get a much better output

vemv16:06:39

I post here a variation of something that I posted in #clojurescript this morning, but is essentially a different problem (it affects JVM clojure) I have a ns l from library L which requires clojure.core.specs.alpha, and uses one of its specs via spec/def. And I have a ns a from app A that requires l. When running A, I get java.lang.Exception: Unable to resolve spec: :clojure.core.specs.alpha/params+body. This doesn't happen when running L. I use the Reloaded workflow with vanilla requires and project organisation. All deps are the latest

vemv17:06:00

@alexmiller : The problem appears to boil down to the fact that just that specific spec is absent from the registry

Alex Miller (Clojure team)18:06:37

there were some core spec renames in the 1.10-era core.specs.alpha - are you seeing mismatches maybe?

Alex Miller (Clojure team)18:06:50

yeah params+body was a rename in 1.10-era from 1.9-era

Alex Miller (Clojure team)18:06:44

changes happened in core.specs.alpha 0.2.44

Alex Miller (Clojure team)18:06:11

so would be good to know the version of that being used by L and A, and also whether aot is happening on L

vemv18:06:46

hi! I've been doing archeology for the last hour and I still can't make sense of things even when using 1.10.1 and the latest clojure.core.specs.alpha dep (stable, or snapshot, or none at all, since it's bundled), (require '[clojure.core.specs.alpha] :reload-all) won't get me the params+body spec in this particular project maybe Leiningen is doing sth evil

vemv18:06:23

no aot in either side. tried lein clean, no luck either

Alex Miller (Clojure team)18:06:25

Clojure 1.10.0
user=> (require '[clojure.core.specs.alpha :as sa])
nil
user=> ::sa/params+body
:clojure.core.specs.alpha/params+body
user=> (require '[clojure.spec.alpha :as s])
nil
user=> (s/get-spec ::sa/params+body)
{:clojure.spec.alpha/op :clojure.spec.alpha/pcat, :ps [:clojure.core.specs.alpha/param-list {:clojure.spec.alpha/op :clojure.spec.alpha/alt, :ps ({:clojure.s...

vemv18:06:49

yes, in the original library ("L") it just works in a larger app ("A") using L it doesn't Did whatever I could to bisect, no luck I'll try creating another app, since A is quite large tbh, increasing the chances for weird interactions

Alex Miller (Clojure team)18:06:08

does the registry contain any of the core.specs.alpha stuff?

vemv18:06:18

most of them yes. see #clojure , found the thing

sveri19:06:47

@alexmiller its the same in the clj repl. But I have a lot of libraries loaded, not sure of something messes around with the output.

plins22:06:27

did some googling but not found the anwser, is it possible to share specs between clj and cljs files? do I need to write .cljx files?

Alex Miller (Clojure team)22:06:39

you can write specs in .cljc files and share them

👍 4
plins23:06:09

any recommended documentation on how to setup clc files and share them? something has to be done in project.clj?

seancorfield00:06:28

@U3QUAHZJ6 It's mostly automatic. The compilers look for both .cljc files and their own suffix (`.clj` or .cljs).

Alex Miller (Clojure team)22:06:07

.cljx is old and shouldn't be used anymore