Fork me on GitHub
#planck
<
2017-03-28
>
slipset07:03:34

Being a bit nit-picky here...

slipset07:03:42

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=>

slipset07:03:54

So of course, I’d like to try/catch this...

slipset07:03:37

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=>

slipset07:03:23

reading through the code, I see that this happens because we end up in planck.repl/eval which has the following piece of code

slipset07:03:38

(if error
           (handle-error error true)

slipset07:03:02

which kind’a prints the error and retuns nil.

slipset07:03:38

Which is not always what one would want.

mfikes11:03:55

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)

mfikes11:03:20

(`'planck.repl/resolve` is actually a private var)

slipset19:03:13

I'd be happy if Planck.core/resolve just threw an exception that I could catch.

mfikes19:03:59

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.

slipset20:03:59

I guess I'm good then, since the code from inf-clojure uses read-string.

slipset20:03:39

(-> "foo" read-string resolve meta :arglist) or some such. On the phone...

slipset20:03:12

Wrapped in a try/catch for good measure.