[Git][ghc/ghc][master] Adjust catches to properly rethrow exceptions
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue Oct 22 00:56:15 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
148059fe by Andrzej Rybczak at 2024-10-21T20:55:40-04:00
Adjust catches to properly rethrow exceptions
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13302 implemented exception
rethrowing proposal, but it didn't adjust `catches`. This fixes it.
- - - - -
1 changed file:
- libraries/ghc-internal/src/GHC/Internal/Control/Exception.hs
Changes:
=====================================
libraries/ghc-internal/src/GHC/Internal/Control/Exception.hs
=====================================
@@ -119,6 +119,7 @@ module GHC.Internal.Control.Exception (
) where
import GHC.Internal.Control.Exception.Base
+import GHC.Internal.Exception.Type (ExceptionWithContext(..), whileHandling)
import GHC.Internal.Base
import GHC.Internal.IO (interruptible)
@@ -149,13 +150,15 @@ Instead, we provide a function 'catches', which would be used thus:
> Handler (\ (ex :: IOException) -> handleIO ex)]
-}
catches :: IO a -> [Handler a] -> IO a
-catches io handlers = io `catch` catchesHandler handlers
-
-catchesHandler :: [Handler a] -> SomeException -> IO a
-catchesHandler handlers e = foldr tryHandler (throw e) handlers
- where tryHandler (Handler handler) res
- = case fromException e of
- Just e' -> handler e'
+catches io handlers = io `catchNoPropagate` catchesHandler handlers
+
+catchesHandler :: [Handler a] -> ExceptionWithContext SomeException -> IO a
+catchesHandler handlers ec@(ExceptionWithContext _ e) =
+ foldr tryHandler (rethrowIO ec) handlers
+ where
+ tryHandler (Handler handler) res =
+ case fromException e of
+ Just e' -> annotateIO (whileHandling ec) (handler e')
Nothing -> res
-- -----------------------------------------------------------------------------
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/148059fea534aced44649c739cd0fad4c25a99f0
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/148059fea534aced44649c739cd0fad4c25a99f0
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241021/9648c813/attachment-0001.html>
More information about the ghc-commits
mailing list