lynaghk / cljx

Write a portable codebase targeting Clojure/ClojureScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error handling in cljx-compile

undernorthernsky opened this issue · comments

Having this bug in project.clj:

:cljx {:builds [{ ; boring
                        :rules clj}]}

caused the rather unhelpful error:

$ lein cljx once
java.lang.NullPointerException
    at clojure.lang.Symbol.intern(Symbol.java:60)
    at clojure.core$symbol.invoke(core.clj:539)
    at cljx.core$cljx_compile.doInvoke(core.clj:85)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at leiningen.cljx$once.invoke(cljx.clj:11)
    at leiningen.cljx$cljx.invoke(cljx.clj:33) ...

I do appreciate the freedom the fallback to resolving symbols in cljx-compile allows - but it causes a steep price for an average user (in a failure case like this).
A little more context (e.g. "NPE while trying to load namespace x") in the error message seems like a good idea.
Maybe even fuzzy checking to catch "clj" and "cljs" as strings / symbols and emit a "Did you actually mean what you wrote in the config?" message.