Skip to content

Commit

Permalink
Add better helper for unwrapping exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Jan 16, 2024
1 parent 484b7f5 commit 60d3f16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ BREAKING CHANGES:
never have been there.



## Version 11.0.678

- Fix internal coercion function (cljs only) that causes unexpected
Expand Down
13 changes: 7 additions & 6 deletions src/promesa/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,25 @@
(instance? TimeoutException e)))

#?(:clj
(defn unwrap-completion-exception
{:no-doc true}
(defn unwrap-exception
"Unwrap CompletionException or ExecutionException"
[cause]
(if (instance? CompletionException cause)
(.getCause ^CompletionException cause)
(if (or (instance? CompletionException cause)
(instance? ExecutionException cause))
(or (ex-cause cause) cause)
cause)))

#?(:clj
(deftype Function2 [f]
java.util.function.BiFunction
(apply [_ r e]
(f r (unwrap-completion-exception e)))))
(f r (unwrap-exception e)))))

#?(:clj
(deftype Consumer2 [f]
java.util.function.BiConsumer
(accept [_ r e]
(f r (unwrap-completion-exception e)))))
(f r (unwrap-exception e)))))

(defn handler
"Create a handler, mainly for combine two separate functions
Expand Down

0 comments on commit 60d3f16

Please sign in to comment.