Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use Slingshot instead of SOAPException hackery.

  • Loading branch information...
commit c96c0ca439b261068cf82e8c195017915c621563 1 parent 2890720
Brian Marick authored
1  project.clj
View
@@ -14,6 +14,7 @@
[leiningen-core "2.0.0-preview10"]
[swiss-arrows "0.1.0"]
[org.clojure/tools.namespace "0.2.2"]
+ [slingshot "0.10.3"]
[commons-codec/commons-codec "1.7"]
[gui-diff "0.3.9"]]
:profiles {:dev {:dependencies [[slamhound "1.2.0"]
18 src/midje/clojure/backwards_compatibility.clj
View
@@ -10,7 +10,16 @@
(defmacro defn-once-in-core [sym & rest]
(when (missing? sym)
- `(intern 'clojure.core '~sym (fn ~@rest)))))
+ `(intern 'clojure.core '~sym (fn ~@rest))))
+
+ (defmacro move-once-to-core [source-namespace syms]
+ (when (missing? (first syms))
+ `(do
+ (require '~source-namespace)
+ (doseq [sym# '~syms]
+ (intern 'clojure.core sym# (ns-resolve '~source-namespace sym#)))))))
+
+(move-once-to-core slingshot.ex-info [ex-info ex-data])
(defn-once every-pred-m
"Takes a set of predicates and returns a function f that returns true if all of its
@@ -91,10 +100,3 @@
([x y z] (some #(or (% x) (% y) (% z)) ps))
([x y z & args] (or (spn x y z)
(some #(some % args) ps)))))))
-
-
-(defn-once-in-core ex-info
- ([msg map]
- (RuntimeException. msg))
- ([msg map cause]
- (RuntimeException. msg cause)))
16 src/midje/parsing/util/error_handling.clj
View
@@ -2,15 +2,13 @@
midje.parsing.util.error-handling
(:use midje.clojure.core
[midje.util.exceptions :only [user-error-exception-lines]]
- [midje.parsing.util.file-position :only [form-position]])
-
+ [midje.parsing.util.file-position :only [form-position]]
+ [slingshot.slingshot :only [throw+ try+]])
(:require [bultitude.core :as bultitude]
- [midje.emission.api :as emit])
- ;; Because exception subclasses are so hard to create, throw
- ;; one of these to indicate parsing has terminated. Seems safe."
- (:import javax.xml.soap.SOAPException))
+ [midje.emission.api :as emit]))
(def ^{:dynamic true} *wrap-count* 0)
+(def bail-out-of-parsing (gensym))
;; Note: this could be a macro, but it's easy to
;; get confused by macros assisting in the execution
@@ -34,9 +32,9 @@
(if (pos? *wrap-count*)
(parser)
(binding [*wrap-count* (inc *wrap-count*)]
- (try
+ (try+
(parser)
- (catch javax.xml.soap.SOAPException ex
+ (catch (partial = bail-out-of-parsing) _
false)
(catch Exception ex
(emit/fail {:type :exception-during-parsing
@@ -51,6 +49,6 @@
(emit/fail {:type :parse-error
:notes notes
:position (form-position form)})
- (throw (new javax.xml.soap.SOAPException)))
+ (throw+ bail-out-of-parsing))
Please sign in to comment.
Something went wrong with that request. Please try again.