File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 41
41
(with-meta [(deref r)] (meta r)))
42
42
43
43
(extend-protocol p/Datafiable
44
+ js/Error
45
+ (datafy [x] (Throwable->map x))
46
+
47
+ ExceptionInfo
48
+ (datafy [x] (Throwable->map x))
49
+
44
50
Var
45
51
(datafy [r] (datify-ref r))
46
52
Original file line number Diff line number Diff line change 22
22
x (with-meta original {`clojure.core.protocols/datafy (fn [_] datafied)})]
23
23
(is (= datafied (d/datafy x)))
24
24
(is (= {:clojure.datafy/obj original} (meta (d/datafy x)))))))
25
+
26
+ (deftest datafy-js-errors-test
27
+ (let [x (js/Error. " foo" )]
28
+ (is (= (Throwable->map x) (d/datafy x))))
29
+ ; ; Ensure we can datafy objects that extend js/Error
30
+ (let [x (js/RangeError. " x must be between 1 and 5" )]
31
+ (is (= (Throwable->map x) (d/datafy x)))))
32
+
33
+ (deftest datafy-ex-info-test
34
+ (let [x (ex-info " foo" {:a 1 } (ex-info " bar" {:b 2 }))]
35
+ (is (= (Throwable->map x) (d/datafy x)))))
You can’t perform that action at this time.
0 commit comments