Skip to content

Instantly share code, notes, and snippets.

@mfikes

mfikes/err-msgs.md

Last active Dec 1, 2018
Embed
What would you like to do?
WIP on ClojureScript Error Messages

Illustration of WIP on CLJS-2913 is in this branch: https://github.com/mfikes/clojurescript/tree/CLJS-2913-WIP

Here are examples exploring :clojure.error/phase :read-source, :macro-syntax-check, :macroexpansion, and :compile-syntax-check

ClojureScript:

$ clj -Srepro -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0-RC2"} org.clojure/clojurescript {:git/url "https://github.com/mfikes/clojurescript" :sha "b43d38a9c7d8dea1438cb8762709d95a3b447d90"}}}' -m cljs.main
cljs.user=> (require 'cljs.core.specs.alpha)
nil
cljs.user=> 08
Syntax error reading source at (REPL:1).
<NO_SOURCE_FILE> [line 1, col 3] Invalid number: 08.
cljs.user=> (if-let 1)
Syntax error macroexpanding cljs.core/if-let at (<cljs repl>:1:1).
1 - failed: vector? at: [:bindings]
cljs.user=> (require 'foo.client)
Unexpected error macroexpanding foo.core/bar at (client.cljs:5:3).
cljs.user=> (if)
Syntax error compiling if at (<cljs repl>:1:1).
Too few arguments to if

Clojure:

$ clj
Clojure 1.10.0-RC2
user=> 08
Syntax error reading source at (REPL:2:0).
Invalid number: 08
user=> (if-let 1)
Syntax error macroexpanding clojure.core/if-let at (REPL:1:1).
1 - failed: vector? at: [:bindings]
user=> (require 'foo.client)
Unexpected error macroexpanding foo.core/bar at (client.clj:5:3).
user=> (if)
Syntax error compiling if at (REPL:1:1).
Too few arguments to if

In the above, client.clj requires foo.core with a macro (defmacro bar [] (throw (RuntimeException.)))

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