Commit 2b5b178f authored by dterei's avatar dterei

Improve Safe Haskell warn/error output.

parent f26027ee
......@@ -1045,7 +1045,7 @@ hscCheckSafe' dflags m l = do
<> text ", to check that it can be safely imported"
-- got iface, check trust
Just iface' -> do
Just iface' ->
let trust = getSafeMode $ mi_trust iface'
trust_own_pkg = mi_trust_pkg iface'
-- check module is trusted
......@@ -1054,15 +1054,17 @@ hscCheckSafe' dflags m l = do
safeP = packageTrusted trust trust_own_pkg m
-- pkg trust reqs
pkgRs = map fst $ filter snd $ dep_pkgs $ mi_deps iface'
case (safeM, safeP) of
-- General errors we throw but Safe errors we log
(True, True ) -> return (trust == Sf_Trustworthy, pkgRs)
(True, False) -> liftIO . throwIO $ pkgTrustErr
(False, _ ) -> logWarnings modTrustErr >>
return (trust == Sf_Trustworthy, pkgRs)
errs = case (safeM, safeP) of
(True, True ) -> emptyBag
(True, False) -> pkgTrustErr
(False, _ ) -> modTrustErr
in do
logWarnings errs
return (trust == Sf_Trustworthy, pkgRs)
where
pkgTrustErr = mkSrcErr $ unitBag $ mkPlainErrMsg dflags l $
pkgTrustErr = unitBag $ mkPlainErrMsg dflags l $
sep [ ppr (moduleName m)
<> text ": Can't be safely imported!"
, text "The package (" <> ppr (modulePackageId m)
......
......@@ -1761,11 +1761,7 @@ checkAdd ii = do
m <- GHC.lookupModule modname pkgqual
when safe $ do
t <- GHC.isModuleTrusted m
when (not t) $
ghcError $ CmdLineError $
"can't import " ++ moduleNameString modname
++ " as it isn't trusted."
when (not t) $ ghcError $ ProgramError $ ""
-- -----------------------------------------------------------------------------
-- Update the GHC API's view of the context
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment