This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-30
Channels
- # aleph (1)
- # beginners (126)
- # cider (2)
- # clara (38)
- # cljsrn (2)
- # clojars (2)
- # clojure (49)
- # clojure-dev (31)
- # clojure-dusseldorf (1)
- # clojure-finland (1)
- # clojure-france (6)
- # clojure-italy (13)
- # clojure-nl (12)
- # clojure-russia (9)
- # clojure-sg (1)
- # clojure-spec (33)
- # clojure-uk (83)
- # clojurescript (206)
- # community-development (3)
- # core-async (40)
- # cursive (4)
- # datomic (7)
- # duct (21)
- # emacs (9)
- # fulcro (36)
- # funcool (2)
- # graphql (12)
- # instaparse (4)
- # jobs (4)
- # lumo (24)
- # mount (1)
- # nyc (4)
- # off-topic (29)
- # onyx (1)
- # pedestal (2)
- # random (4)
- # re-frame (60)
- # reagent (136)
- # remote-jobs (1)
- # schema (1)
- # shadow-cljs (20)
- # spacemacs (6)
- # specter (14)
- # tools-deps (2)
I’m trying to find a nicer way to report simple errors based on clojure’s core specs….
In the case of a spec error, you should get an ExceptionInfo where ex-data has the explain data
Or you can hook s/*explain-out*
@raymcdermott do you read and eval input from user?
Than this could work (although not sure if that's an optimal way to do it)
(try (eval (read-string "(defn foo 1)")) (catch Exception e (ex-data (.getCause e))))
I’m reading the results of evaluation via the PREPL which gives back a string for the :val
key
@alexmiller I’m using the PREPL from 1.10 and it would be nice (IMHO) if there was a property for spec fails
I’m a little confused by what you’re saying. In the case of an exception, I would expect prepl to be converting the Throwable to data with Throwable->map
which captures ex-data in a :data
attribute.
trying some things in the repl, I understand what you’re saying I think, although I don’t understand why
oh, I’m testing with io-prepl and it’s happening due to the default valf of pr-str - is that what you’re using @raymcdermott?
if you use a valf of identity, then you’ll get back throwables as data
Clojure 1.10.0-master-SNAPSHOT
user=> (require '[clojure.core.server :as ccs])
nil
user=> (ccs/io-prepl :valf identity)
(defn foo 1)
{:tag :ret,
:val {:cause "Call to clojure.core/defn did not conform to spec:\nIn: [1] val: 1 fails spec: :clojure.core.specs.alpha/arg-list ...",
:via [{:type clojure.lang.Compiler$CompilerException,
:message "clojure.lang.ExceptionInfo: Call to clojure.core/defn did not conform...",
:at [clojure.lang.Compiler checkSpecs "Compiler.java" 6891]}
{:type clojure.lang.ExceptionInfo,
:message "Call to clojure.core/defn did not conform ...",
#_here :data #:clojure.spec.alpha{:problems (
{:path [:args :bs :arity-1 :args],
:pred clojure.core/vector?,
:val 1,
:via ...
`thanks @alexmiller I’ll give it a shot later
@alexmiller I could be doing it wrong but I’m using io-prepl as part of a socket-server like this…
Read failclojure.lang.LispReader$ReaderException: java.lang.RuntimeException: No reader function for tag object 1
Read fail: clojure.lang.EdnReader$ReaderException: java.lang.RuntimeException: No reader function for tag object
I haven’t put all these pieces together recently and don’t have time to look at it today. you might look at wrapping clj-server/remote-prepl for the client side?
and since stuff is mostly char stream based, you might just want the defaults in io-prepl but to read on the remote-prepl valf side, not sure
thanks @alexmiller