Yeah, while doing more testing it seems to depend from where the
ClassNotFoundException is thrown. What I was trying to do at first is
to call extend-type on a Java class only if it exists. Surrounding
extend-type by a try..catch clause doesn't work here. So I tried to
simply type:

user> (try org.postgresql.PGConnection (catch ClassNotFoundException
e :catched))
; Evaluation aborted.

And, as you see, the try..catch didn't work either. But I just found
out that when using Clojure internal classForName method it can be
catched:

user> (try (clojure.lang.RT/classForName
"org.postgresql.PGConnection" ) (catch ClassNotFoundException
e :catched))
:catched

So we could always use RT/classForName to detect what classes are
available. Do you think the extend-type thrown exception can possibly
be fixed or is it a fundamental limitation?

On Dec 15, 9:27 pm, Stuart Halloway <stuart.hallo...@gmail.com> wrote:
> Can you post an example?
>
> (try
>  (throw (ClassNotFoundException. "What makes you say that?"))
>  (catch ClassNotFoundException e
>    (println (.getMessage e))))
>
> > Hi, is there a way of catching ClassNotFoundException? Using
> > try..catch doesn't work!
>
> > Thanks
>
> > --
> > 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
>
>

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

Reply via email to