When running with ghc -e, exceptions should claim to be from the program
that we are running, not ghc.
import Control.Monad as Monad
import Text.Printf
import Foreign
import Control.Monad as Monad
import Text.Printf
import Foreign
-import Foreign.C ( withCStringLen )
import GHC.Exts ( unsafeCoerce# )
import GHC.IOBase ( IOErrorType(InvalidArgument) )
import GHC.Exts ( unsafeCoerce# )
import GHC.IOBase ( IOErrorType(InvalidArgument) )
import Data.IORef ( IORef, readIORef, writeIORef )
import Data.IORef ( IORef, readIORef, writeIORef )
Just exprs -> do
-- just evaluate the expression we were given
enqueueCommands exprs
Just exprs -> do
-- just evaluate the expression we were given
enqueueCommands exprs
- let handleEval (ExitException code) = io (exitWith code)
- handleEval e = handler e
- runCommands' handleEval (return Nothing)
+ let handle e = do st <- getGHCiState
+ -- Jump through some hoops to get the
+ -- current progname in the exception text:
+ -- <progname>: <exception>
+ io $ withProgName (progname st)
+ -- The "fast exit" part just calls exit()
+ -- directly instead of doing an orderly
+ -- runtime shutdown, otherwise the main
+ -- GHCi thread will complain about being
+ -- interrupted.
+ $ topHandlerFastExit e
+ runCommands' handle (return Nothing)
-- and finally, exit
io $ do when (verbosity dflags > 0) $ putStrLn "Leaving GHCi."
-- and finally, exit
io $ do when (verbosity dflags > 0) $ putStrLn "Leaving GHCi."
interactiveLoop :: Bool -> Bool -> GHCi ()
interactiveLoop is_tty show_prompt =
-- Ignore ^C exceptions caught here
interactiveLoop :: Bool -> Bool -> GHCi ()
interactiveLoop is_tty show_prompt =
-- Ignore ^C exceptions caught here