Being a bit nit-picky here...
cljs.user=> (planck.repl/resolve "does-not-exist")
Could not eval (var "does-not-exist")
Doesn't support namespace: does-not-exist
nil
cljs.user=>
So of course, I’d like to try/catch this...
cljs.user=> (try (planck.repl/resolve "does-not-exist") (catch :default e (println "wat")))
Could not eval (var "does-not-exist")
Doesn't support namespace: does-not-exist
nil
cljs.user=>
reading through the code, I see that this happens because we end up in planck.repl/eval
which has the following piece of code
(if error
(handle-error error true)
which kind’a prints the error and retuns nil.
Which is not always what one would want.
@slipset Good catch. https://github.com/mfikes/planck/issues/467
Perhaps this is a case of functions assuming their arguments are correct (for perf reasons), and when not, undefined behavior occurs. (FWIW, Planck catches the issue if you instrument 'planck.core/resolve
)
(`'planck.repl/resolve` is actually a private var)
I'd be happy if Planck.core/resolve just threw an exception that I could catch.
What is resolve supposed to do? I suppose if you try to resolve a symbol that doesn't exist, that kind of stuff is covered. But if you pass in a non-symbol, it is not clear to me that your program is correct.
I guess I'm good then, since the code from inf-clojure uses read-string.
(-> "foo" read-string resolve meta :arglist) or some such. On the phone...
Wrapped in a try/catch for good measure.