aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/condition/Condition.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/clojure/contrib/condition/Condition.clj')
-rw-r--r--src/clojure/contrib/condition/Condition.clj26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/clojure/contrib/condition/Condition.clj b/src/clojure/contrib/condition/Condition.clj
index b3a24340..18449653 100644
--- a/src/clojure/contrib/condition/Condition.clj
+++ b/src/clojure/contrib/condition/Condition.clj
@@ -16,16 +16,28 @@
(ns clojure.contrib.condition.Condition
(:gen-class :extends Throwable
:implements [clojure.lang.IMeta]
- :state _meta
+ :state state
:init init
- :constructors
- {[clojure.lang.IPersistentMap] []}))
+ :post-init post-init
+ :constructors {[clojure.lang.IPersistentMap]
+ [String Throwable]}))
(defn -init
- [meta]
- [[] meta])
+ "Constructs a Condition object with condition (a map) as its
+ metadata. Also initializes the superclass with the values at :message
+ and :cause, if any, so they are also available via .getMessage and
+ .getCause."
+ [condition]
+ [[(:message condition) (:cause condition)] (atom condition)])
+
+(defn -post-init
+ "Adds :stack-trace to the condition. Drops the bottom 3 frames because
+ they are always the same: implementation details of Condition and raise."
+ [this condition]
+ (swap! (.state this) assoc
+ :stack-trace (into-array (drop 3 (.getStackTrace this)))))
(defn -meta
+ "Returns this object's metadata, the condition"
[this]
- (assoc (._meta this)
- :stack-trace (into-array (drop 3 (.getStackTrace this)))))
+ @(.state this))