From 60d3f16c6d75bdb10ffbc42c8d8294bd2df159b7 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 16 Jan 2024 23:54:00 +0100 Subject: [PATCH] Add better helper for unwrapping exceptions --- CHANGELOG.md | 1 + src/promesa/util.cljc | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f54898..335c837 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ BREAKING CHANGES: never have been there. + ## Version 11.0.678 - Fix internal coercion function (cljs only) that causes unexpected diff --git a/src/promesa/util.cljc b/src/promesa/util.cljc index 8de634c..8ac0a8c 100644 --- a/src/promesa/util.cljc +++ b/src/promesa/util.cljc @@ -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