[commit: ghc] master: GhcApiError now contains a String, not an SDoc (4e78c8a)
Ian Lynagh
igloo at earth.li
Wed Jun 13 17:16:28 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/4e78c8a0387263ee26cf380700769720aefb57c1
>---------------------------------------------------------------
commit 4e78c8a0387263ee26cf380700769720aefb57c1
Author: Ian Lynagh <igloo at earth.li>
Date: Tue Jun 12 16:00:21 2012 +0100
GhcApiError now contains a String, not an SDoc
>---------------------------------------------------------------
compiler/main/GHC.hs | 9 ++++++---
compiler/main/HscTypes.lhs | 8 ++++----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
index 27f6f96..dc0730f 100644
--- a/compiler/main/GHC.hs
+++ b/compiler/main/GHC.hs
@@ -719,9 +719,11 @@ getModSummary :: GhcMonad m => ModuleName -> m ModSummary
getModSummary mod = do
mg <- liftM hsc_mod_graph getSession
case [ ms | ms <- mg, ms_mod_name ms == mod, not (isBootSummary ms) ] of
- [] -> throw $ mkApiErr (text "Module not part of module graph")
+ [] -> do dflags <- getDynFlags
+ throw $ mkApiErr dflags (text "Module not part of module graph")
[ms] -> return ms
- multiple -> throw $ mkApiErr (text "getModSummary is ambiguous: " <+> ppr multiple)
+ multiple -> do dflags <- getDynFlags
+ throw $ mkApiErr dflags (text "getModSummary is ambiguous: " <+> ppr multiple)
-- | Parse a module.
--
@@ -1182,7 +1184,8 @@ getModuleSourceAndFlags :: GhcMonad m => Module -> m (String, StringBuffer, DynF
getModuleSourceAndFlags mod = do
m <- getModSummary (moduleName mod)
case ml_hs_file $ ms_location m of
- Nothing -> throw $ mkApiErr (text "No source available for module " <+> ppr mod)
+ Nothing -> do dflags <- getDynFlags
+ throw $ mkApiErr dflags (text "No source available for module " <+> ppr mod)
Just sourceFile -> do
source <- liftIO $ hGetStringBuffer sourceFile
return (sourceFile, source, ms_hspp_opts m)
diff --git a/compiler/main/HscTypes.lhs b/compiler/main/HscTypes.lhs
index ff618e0..6298192 100644
--- a/compiler/main/HscTypes.lhs
+++ b/compiler/main/HscTypes.lhs
@@ -181,8 +181,8 @@ mkSrcErr = SourceError
srcErrorMessages :: SourceError -> ErrorMessages
srcErrorMessages (SourceError msgs) = msgs
-mkApiErr :: SDoc -> GhcApiError
-mkApiErr = GhcApiError
+mkApiErr :: DynFlags -> SDoc -> GhcApiError
+mkApiErr _ msg = GhcApiError (showSDoc msg)
throwOneError :: MonadIO m => ErrMsg -> m ab
throwOneError err = liftIO $ throwIO $ mkSrcErr $ unitBag err
@@ -221,11 +221,11 @@ handleSourceError handler act =
gcatch act (\(e :: SourceError) -> handler e)
-- | An error thrown if the GHC API is used in an incorrect fashion.
-newtype GhcApiError = GhcApiError SDoc
+newtype GhcApiError = GhcApiError String
deriving Typeable
instance Show GhcApiError where
- show (GhcApiError msg) = showSDoc msg
+ show (GhcApiError msg) = msg
instance Exception GhcApiError
More information about the Cvs-ghc
mailing list