Skip to content

Commit

Permalink
contrib.debug/instrument* catches transfer exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurC committed May 10, 2024
1 parent 944984c commit 831d1e6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/contrib/debug.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@
(reify
IFn (#?(:clj invoke :cljs -invoke) [_] (prn nm id :cancelled) (it))
IDeref (#?(:clj deref :cljs -deref) [_]
(let [v @it]
(let [v (try @it (catch #?(:clj Throwable :cljs :default) e [::ex e]))]
(prn nm id :transferred
(if (instance? Failure v)
(let [e (.-error v)]
[(type e) (ex-message e)])
v))
v))))))
(if (and (vector? v) (= ::ex (first v)))
(throw (second v))
v)))))))
(defmacro instrument [nm & body] `(new (instrument* ~nm (hyperfiddle.electric/fn [] ~@body))))

0 comments on commit 831d1e6

Please sign in to comment.