If I remember right from looking at clojure.contrib.condition's source (which I did because I wrote a similar error handling lib, which has a few extra features but isn't ready for prime time)...
"handle" doesn't actually exist as a function or macro. It doesn't expand - the handler-case macro looks for it and basically drops the symbol "handle" and uses the rest of the form to create a function. I would think the unquote-quote should leave "handle" unqualified and do the right thing, but apparently not. https://github.com/richhickey/clojure-contrib/blob/ec6a7579d6b1c0bfa42e3666cfad196cffc966fe/src/main/clojure/clojure/contrib/condition.clj#L71 I believe somehow the (= 'handle (first %)) comparison on line 92 is returning false on your handle form. I am not sure why. But that might be worth exploring at the repl. Jeff On Feb 1, 4:09 pm, "Straszheim, Jeff" <jstra...@akamai.com> wrote: > So, I have a macro that looks something like this: > > (defmacro test-failure > [& forms] > `(handler-case :type > ~@forms > (~'handle :error/error > (println "error happened")))) > > (My real macro is more complex, but this gives the idea.) > > If I eval > > (test-failure (println "test")) > > I get: > > => Unable to resolve symbol: handle in this context > > However, if I macroexpand-1 the thing, I get: > > (macroexpand-1 '(test-failure (println "test"))) > > => (clojure.contrib.condition/handler-case :type (println "test") (handle > :error/error (clojure.core/println "error happened"))) > > That is correct, and if I eval just that it works fine. > > Here is an interesting thing: if I do this: > > (macroexpand '(test-failure (println "test"))) > > I get > > => (try (println "test") (handle :error/error (clojure.core/println "error > happened")) (catch clojure.contrib.condition.Condition c__19__auto__ > (clojure.core/binding [clojure.contrib.condition/*condition-object* > c__19__auto__ clojure.contrib.condition/*condition* (clojure.core/meta > c__19__auto__) clojure.contrib.condition/*selector* (:type (clojure.core/meta > c__19__auto__))] (clojure.core/cond :else > (clojure.contrib.condition/raise))))) > > It's expanded the handler-case part, but the "handle" is still there. That > seems wrong to me. > > I've tried lots of different ways to specify handle besides ~'handle, but > they all seem to fail. > > Any suggestions? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en