OK, I'm not sure if I'm just missing something obvious here, or if there
really is no way to do this.
What I want to be able to do is to be able to create new exception classes,
in the repl, and be able to throw them and catch them. What I want to be
able to do is something like:
(defexception my-new-exception)
(defn foo []
(throw (my-new-exception)))
(defn bar []
(try
(foo)
(catch my-new-exception e ...)))
I can't figure out how to do this.
- gen-class only generates the class during AOT compilation. This solution
needs to work at the REPL.
- Exceptions need to inherit from java.lang.Throwable- not just wrap it. So
proxy doesn't work, nor does datatypes or protocols (I think).
- java.lang.Throwable is a concrete class, not an interface, so deftype and
defrecord don't work.
- I'd rather not drop down to ASM level to get things to work.
- I'd rather deal with ASM than have to write Java code for every new
exception I need.
I'm kind of surprised I'm the first person who hit this problem. In fact,
I'd be very surprised if that were the case. So what's the normal solution
to this problem?
Brian
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en