Skip to content

Instantly share code, notes, and snippets.

@marcomorain
Last active October 17, 2018 08:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcomorain/170f9c6c68542450b21a451a8ee58e13 to your computer and use it in GitHub Desktop.
Save marcomorain/170f9c6c68542450b21a451a8ee58e13 to your computer and use it in GitHub Desktop.
Clojure Error Messages

Clojure 1.8

$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.8.0"}}}'
Clojure 1.8.0
user=>  (let [2])
IllegalArgumentException let requires an even number of forms in binding vector in user:1  clojure.core/let (core.clj:4333)

Clojure 1.9

$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.9.0"}}}'
Clojure 1.9.0
user=>  (let [2])
CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/let did not conform to spec:
In: [0 0] val: 2 fails spec: :clojure.core.specs.alpha/local-name at: [:args :bindings :binding :sym] predicate: simple-symbol?
In: [0 0] val: 2 fails spec: :clojure.core.specs.alpha/seq-binding-form at: [:args :bindings :binding :seq] predicate: vector?
In: [0 0] val: 2 fails spec: :clojure.core.specs.alpha/map-bindings at: [:args :bindings :binding :map] predicate: coll?
In: [0 0] val: 2 fails spec: :clojure.core.specs.alpha/map-special-binding at: [:args :bindings :binding :map] predicate: map?
 #:clojure.spec.alpha{:problems ({:path [:args :bindings :binding :sym], :pred clojure.core/simple-symbol?, :val 2, :via [:clojure.core.specs.alpha/bindings :clojure.core.specs.alpha/bindings :clojure.core.specs.alpha/binding :clojure.core.specs.alpha/binding-form :clojure.core.specs.alpha/binding-form :clojure.core.specs.alpha/local-name], :in [0 0]} {:path [:args :bindings :binding :seq], :pred clojure.core/vector?, :val 2, :via [:clojure.core.specs.alpha/bindings :clojure.core.specs.alpha/bindings :clojure.core.specs.alpha/binding :clojure.core.specs.alpha/binding-form :clojure.core.specs.alpha/binding-form :clojure.core.specs.alpha/seq-binding-form], :in [0 0]} {:path [:args :bindings :binding :map], :pred clojure.core/coll?, :val 2, :via [:clojure.core.specs.alpha/bindings :clojure.core.specs.alpha/bindings :clojure.core.specs.alpha/binding :clojure.core.specs.alpha/binding-form :clojure.core.specs.alpha/binding-form :clojure.core.specs.alpha/map-binding-form :clojure.core.specs.alpha/map-bindings], :in [0 0]} {:path [:args :bindings :binding :map], :pred map?, :val 2, :via [:clojure.core.specs.alpha/bindings :clojure.core.specs.alpha/bindings :clojure.core.specs.alpha/binding :clojure.core.specs.alpha/binding-form :clojure.core.specs.alpha/binding-form :clojure.core.specs.alpha/map-binding-form :clojure.core.specs.alpha/map-special-binding], :in [0 0]}), :spec #object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x64ba3208 "clojure.spec.alpha$regex_spec_impl$reify__2436@64ba3208"], :value ([2]), :args ([2])}, compiling:(NO_SOURCE_PATH:1:2)

Clojure 1.10.0-RC1

$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0-RC1"}}}'
Clojure 1.10.0-RC1
user=>  (let [2])
Syntax error macroexpanding clojure.core/let at (1:2).
[2] - failed: even-number-of-forms? at: [:bindings] spec: :clojure.core.specs.alpha/bindings
@puredanger
Copy link

It's hard to see in simple examples like this but in the 1.10 one, "(1:2)" is eliding the non-existent source file. If this is encountered in a source file while loading, that will be something like "(foo.clj:1:2)". Also, the exception you get in 1.10 has ex-data with detailed data:

user=> (ex-data *e)
#:clojure.error{:line 1, :column 1, :phase :macroexpand, :source "NO_SOURCE_PATH", :symbol clojure.core/let}

@hlship
Copy link

hlship commented Oct 16, 2018

If you are using io.aviso/pretty, you'll see that ex-data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment