I ran into an interesting problem while porting appengine-magic to
Clojure 1.3.0.

The Google App Engine SDK uses checked exceptions on many of its API
methods. In many cases, I want to catch these exceptions and do
something Clojure-friendly with them. With Clojure 1.2.x, I had no
trouble catching checked exceptions by type, e.g.:

(try
  (some-app-engine-api-methods-called-here ...)
  (catch EntityNotFoundException ex ...))

This stopped working in 1.3.0. The caught exception does not match
EntityNotFoundException; it is now a RuntimeException with the
original typed exception chained to it.

I don't fully understand the implications of the exception handling
changes in 1.3 (https://github.com/clojure/clojure/commit/
8fda34e4c77cac079b711da59d5fe49b74605553). Does it mean that all
exceptions coming in from Java code into Clojure will now be wrapped
in an extra RuntimeException?

If so, then typed catch clauses become useless, and the equivalent
functionality will require writing code like this:

(catch Exception ex
  (cond (isa? (class (.getCause ex)) EntityNotFoundException) ...))

I can wrap that in some kind of a catch* macro (which would also
support directly catching an exception for Clojure 1.2.x
compatibility), but I'm wondering if I'm doing something wrong here.

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