I'm trying to write a macro which will catch a compile time error in Clojure. Specifically, I would like to catch exceptions thrown when a protocol method, which has not been implemented for that datatype, is called and clojure.lang.Compiler$CompilerException is thrown.
So far I have:
(defmacro catch-compiler-error
[body]
(try
(eval body)
(catch Exception e e)))
But of course, I've been told that eval is evil and that you don't typically need to use it. Is there a way to implement this without using eval?
I'm inclined to believe that eval is appropriate here since I specifically want the code to be evaluated at runtime and not at compile time.