On Mon, Feb 16, 2009 at 1:50 AM, David Nolen <dnolen.li...@gmail.com> wrote:
>
>> I don't quite understand why you got through all that work to get
>> error-str -- isn't it just (str (qualify-sym error-type))?
>>
>> ...and since you then use it only as an arg to 'symbol' or 'str', you
>> could just use the symbol itself instead of converting it to a string
>> and back.
>
> If I bring the symbol back directly, it gets evaluated to the actual error
> object and not the symbol.  I want to compare symbols. Or maybe I don't,
> comparing symbols in general seems simpler for meta-hacky stuff like this.

Ah, I see the problem.  You needed a string so that your expansion
could include, for example:

  (symbol "clojure.contrib.error-kit/*error*")

But another way to get that result is for the expansion to instead
include:

  'clojure.contrib.error-kit/*error*

I think you'll find this does exactly the same thing as yours.  Note
the '~error-name:

(defmethod assert-expr 'raised? [msg [_ error-type & body :as form]]
  (let [error-name (qualify-sym error-type)]
    `(with-handler
       (do
         ~...@body
         (report :fail ~msg '~form ~(str error-name " not raised.")))
       (handle ~error-type {:as err#}
         (if (= (:tag err#) '~error-name)
           (report :pass ~msg '~form nil)
           (report :fail ~msg '~form ~(str error-name " was raised."))))
       (handle *error* {:as err#}
         (report :fail ~msg '~form (:tag err#))))))

hm, I think the second :fail message there may not be right.

--Chouser

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

Reply via email to