Skip to content

Commit 60d3f16

Browse files
committed
Add better helper for unwrapping exceptions
1 parent 484b7f5 commit 60d3f16

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ BREAKING CHANGES:
2323
never have been there.
2424

2525

26+
2627
## Version 11.0.678
2728

2829
- Fix internal coercion function (cljs only) that causes unexpected

src/promesa/util.cljc

+7-6
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,25 @@
6767
(instance? TimeoutException e)))
6868

6969
#?(:clj
70-
(defn unwrap-completion-exception
71-
{:no-doc true}
70+
(defn unwrap-exception
71+
"Unwrap CompletionException or ExecutionException"
7272
[cause]
73-
(if (instance? CompletionException cause)
74-
(.getCause ^CompletionException cause)
73+
(if (or (instance? CompletionException cause)
74+
(instance? ExecutionException cause))
75+
(or (ex-cause cause) cause)
7576
cause)))
7677

7778
#?(:clj
7879
(deftype Function2 [f]
7980
java.util.function.BiFunction
8081
(apply [_ r e]
81-
(f r (unwrap-completion-exception e)))))
82+
(f r (unwrap-exception e)))))
8283

8384
#?(:clj
8485
(deftype Consumer2 [f]
8586
java.util.function.BiConsumer
8687
(accept [_ r e]
87-
(f r (unwrap-completion-exception e)))))
88+
(f r (unwrap-exception e)))))
8889

8990
(defn handler
9091
"Create a handler, mainly for combine two separate functions

0 commit comments

Comments
 (0)