File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,7 +189,8 @@ withAsyncUsing doFork = \action inner -> do
189189
190190
191191-- | This function attempts at rethrowing while keeping the context
192- -- This is internal and only working with GHC >=9.12
192+ -- This is internal and only working with GHC >=9.12, otherwise it fallsback to
193+ -- standard 'throwIO'
193194rethrowIO' :: SomeException -> IO a
194195#if MIN_VERSION_base(4,21,0)
195196rethrowIO' e =
@@ -242,7 +243,20 @@ poll = atomically . pollSTM
242243waitSTM :: Async a -> STM a
243244waitSTM a = do
244245 r <- waitCatchSTM a
245- either throwSTM return r
246+ either (rethrowSTM) return r
247+
248+ -- | This function attempts at rethrowing while keeping the context
249+ -- This is internal and only working with GHC >=9.12, otherwise it fallsback to
250+ -- standard 'throwSTM'
251+ rethrowSTM :: SomeException -> STM a
252+ #if MIN_VERSION_base(4,21,0)
253+ rethrowSTM e =
254+ case fromException e of
255+ Just (e' :: ExceptionWithContext SomeException ) -> throwSTM (NoBacktrace e')
256+ Nothing -> throwSTM e
257+ #else
258+ rethrowSTM = throwSTM
259+ #endif
246260
247261-- | A version of 'waitCatch' that can be used inside an STM transaction.
248262--
You can’t perform that action at this time.
0 commit comments