summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2013-01-30 16:37:54 +0000
committerIan Lynagh <ian@well-typed.com>2013-01-30 17:43:45 +0000
commite40299c36c48a41e97f05d7be17042034fd24007 (patch)
treecc5579e4ed16a3494fe05187f4e44572c7d847bd /compiler
parent45df0266679dcf8b92142809fe4c8f4fcd1871cd (diff)
downloadhaskell-e40299c36c48a41e97f05d7be17042034fd24007.tar.gz
Use throwIO rather than throw
Diffstat (limited to 'compiler')
-rw-r--r--compiler/main/ErrUtils.lhs3
-rw-r--r--compiler/main/GHC.hs12
-rw-r--r--compiler/main/SysTools.lhs2
-rw-r--r--compiler/utils/Exception.hs2
4 files changed, 10 insertions, 9 deletions
diff --git a/compiler/main/ErrUtils.lhs b/compiler/main/ErrUtils.lhs
index e0d6a9643e..3fd92ed473 100644
--- a/compiler/main/ErrUtils.lhs
+++ b/compiler/main/ErrUtils.lhs
@@ -52,6 +52,7 @@ import Data.IORef
import Data.Ord
import Data.Time
import Control.Monad
+import Control.Monad.IO.Class
import System.IO
-- -----------------------------------------------------------------------------
@@ -360,6 +361,6 @@ prettyPrintGhcErrors dflags
PprProgramError str doc ->
pprDebugAndThen dflags pgmError str doc
_ ->
- throw e
+ liftIO $ throwIO e
\end{code}
diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
index 5db2de4f41..ee40a1343d 100644
--- a/compiler/main/GHC.hs
+++ b/compiler/main/GHC.hs
@@ -348,7 +348,7 @@ defaultErrorHandler fm (FlushOut flushOut) inner =
Just StackOverflow ->
fatalErrorMsg'' fm "stack overflow: use +RTS -K<size> to increase it"
_ -> case fromException exception of
- Just (ex :: ExitCode) -> throw ex
+ Just (ex :: ExitCode) -> liftIO $ throwIO ex
_ ->
fatalErrorMsg'' fm
(show (Panic (show exception)))
@@ -748,10 +748,10 @@ getModSummary mod = do
mg <- liftM hsc_mod_graph getSession
case [ ms | ms <- mg, ms_mod_name ms == mod, not (isBootSummary ms) ] of
[] -> do dflags <- getDynFlags
- throw $ mkApiErr dflags (text "Module not part of module graph")
+ liftIO $ throwIO $ mkApiErr dflags (text "Module not part of module graph")
[ms] -> return ms
multiple -> do dflags <- getDynFlags
- throw $ mkApiErr dflags (text "getModSummary is ambiguous: " <+> ppr multiple)
+ liftIO $ throwIO $ mkApiErr dflags (text "getModSummary is ambiguous: " <+> ppr multiple)
-- | Parse a module.
--
@@ -1213,7 +1213,7 @@ getModuleSourceAndFlags mod = do
m <- getModSummary (moduleName mod)
case ml_hs_file $ ms_location m of
Nothing -> do dflags <- getDynFlags
- throw $ mkApiErr dflags (text "No source available for module " <+> ppr mod)
+ liftIO $ throwIO $ mkApiErr dflags (text "No source available for module " <+> ppr mod)
Just sourceFile -> do
source <- liftIO $ hGetStringBuffer sourceFile
return (sourceFile, source, ms_hspp_opts m)
@@ -1231,7 +1231,7 @@ getTokenStream mod = do
POk _ ts -> return ts
PFailed span err ->
do dflags <- getDynFlags
- throw $ mkSrcErr (unitBag $ mkPlainErrMsg dflags span err)
+ liftIO $ throwIO $ mkSrcErr (unitBag $ mkPlainErrMsg dflags span err)
-- | Give even more information on the source than 'getTokenStream'
-- This function allows reconstructing the source completely with
@@ -1244,7 +1244,7 @@ getRichTokenStream mod = do
POk _ ts -> return $ addSourceToTokens startLoc source ts
PFailed span err ->
do dflags <- getDynFlags
- throw $ mkSrcErr (unitBag $ mkPlainErrMsg dflags span err)
+ liftIO $ throwIO $ mkSrcErr (unitBag $ mkPlainErrMsg dflags span err)
-- | Given a source location and a StringBuffer corresponding to this
-- location, return a rich token stream with the source associated to the
diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs
index e648481cd3..40a7a25ccd 100644
--- a/compiler/main/SysTools.lhs
+++ b/compiler/main/SysTools.lhs
@@ -540,7 +540,7 @@ runClang dflags args = do
text ("Error running clang! you need clang installed to use the" ++
"LLVM backend") $+$
text "(or GHC tried to execute clang incorrectly)"
- throw err
+ throwIO err
)
-- | Figure out which version of LLVM we are running this session
diff --git a/compiler/utils/Exception.hs b/compiler/utils/Exception.hs
index 9d196fd843..b4908997a8 100644
--- a/compiler/utils/Exception.hs
+++ b/compiler/utils/Exception.hs
@@ -93,5 +93,5 @@ ghandle = flip gcatch
gonException :: (ExceptionMonad m) => m a -> m b -> m a
gonException ioA cleanup = ioA `gcatch` \e ->
do _ <- cleanup
- throw (e :: SomeException)
+ liftIO $ throwIO (e :: SomeException)