diff options
Diffstat (limited to 'libraries/ghci/GHCi/Run.hs')
-rw-r--r-- | libraries/ghci/GHCi/Run.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libraries/ghci/GHCi/Run.hs b/libraries/ghci/GHCi/Run.hs index 858b247f65..fefbdc32c1 100644 --- a/libraries/ghci/GHCi/Run.hs +++ b/libraries/ghci/GHCi/Run.hs @@ -10,6 +10,7 @@ -- module GHCi.Run ( run, redirectInterrupts + , toSerializableException, fromSerializableException ) where import GHCi.CreateBCO @@ -35,6 +36,7 @@ import Foreign import Foreign.C import GHC.Conc.Sync import GHC.IO hiding ( bracket ) +import System.Exit import System.Mem.Weak ( deRefWeak ) import Unsafe.Coerce @@ -221,6 +223,17 @@ tryEval io = do Left ex -> return (EvalException (toSerializableException ex)) Right a -> return (EvalSuccess a) +toSerializableException :: SomeException -> SerializableException +toSerializableException ex + | Just UserInterrupt <- fromException ex = EUserInterrupt + | Just (ec::ExitCode) <- fromException ex = (EExitCode ec) + | otherwise = EOtherException (show (ex :: SomeException)) + +fromSerializableException :: SerializableException -> SomeException +fromSerializableException EUserInterrupt = toException UserInterrupt +fromSerializableException (EExitCode c) = toException c +fromSerializableException (EOtherException str) = toException (ErrorCall str) + -- This function sets up the interpreter for catching breakpoints, and -- resets everything when the computation has stopped running. This -- is a not-very-good way to ensure that only the interactive |