Skip to content

Commit

Permalink
Fixed a Clojure 1.3.0 incompatibility with exception handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
gcv committed Oct 3, 2011
1 parent 4942b50 commit acc80e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/appengine_magic/services/datastore.clj
Expand Up @@ -374,7 +374,12 @@
:or {kind (unqualified-name (.getName entity-record-type))}}] :or {kind (unqualified-name (.getName entity-record-type))}}]
(try (try
(retrieve-helper entity-record-type key-value-or-values :parent parent :kind kind) (retrieve-helper entity-record-type key-value-or-values :parent parent :kind kind)
(catch EntityNotFoundException _ nil))) ;; XXX: Clojure 1.2.x only:
(catch EntityNotFoundException _ nil)
;; XXX: Clojure 1.3.x:
(catch Exception ex (if (isa? (class (.getCause ex)) EntityNotFoundException)
nil
(throw ex)))))




(defn exists? [entity-record-type key-value-or-values & (defn exists? [entity-record-type key-value-or-values &
Expand Down
2 changes: 2 additions & 0 deletions test/test/appengine_magic/services/datastore.clj
Expand Up @@ -38,6 +38,8 @@
(is (= alice alice-queried)) (is (= alice alice-queried))
(is (= bob bob-retrieved)) (is (= bob bob-retrieved))
(is (= charlie charlie-retrieved))) (is (= charlie charlie-retrieved)))
;; retrieve non-stored entity
(is (nil? (ds/retrieve Author "Drew")))
;; sorted query ;; sorted query
(let [[charlie-queried bob-queried alice-queried] (ds/query :kind Author (let [[charlie-queried bob-queried alice-queried] (ds/query :kind Author
:sort [[:name :desc]])] :sort [[:name :desc]])]
Expand Down

0 comments on commit acc80e5

Please sign in to comment.