@@ -12,6 +12,7 @@ import Control.Concurrent.Async (Async, async, waitCatch)
1212import Control.Concurrent.Strict (modifyVar , newVar )
1313import Control.DeepSeq (force , rwhnf )
1414import Control.Exception (evaluate , mask , throwIO )
15+ import qualified Control.Exception as Exc
1516import Control.Monad.Extra (eitherM , join , mapMaybeM )
1617import Data.Either (fromRight )
1718import Data.IORef
@@ -56,24 +57,24 @@ newHscEnvEq hscEnv' = do
5657#if MIN_VERSION_ghc(9,11,0)
5758 let hscEnv = hscEnv'
5859 { hsc_FC = FinderCache
59- { flushFinderCaches = \ _ -> error " GHC should never call flushFinderCaches outside the driver"
60+ { flushFinderCaches = \ _ -> throwIO $ Exc. ErrorCall " flushFinderCaches: GHC should never call flushFinderCaches outside the driver"
6061#if MIN_VERSION_ghc(9,13,0)
6162 , addToFinderCache = \ im val -> do
6263#else
6364 , addToFinderCache = \ (GWIB im _) val -> do
6465#endif
6566 if moduleUnit im `elem` hsc_all_home_unit_ids hscEnv'
66- then error " tried to add home module to FC"
67+ then throwIO $ Exc. ErrorCall " addToFinderCache: tried to add home module to FC"
6768 else atomicModifyIORef' mod_cache $ \ c -> (extendInstalledModuleEnv c im val, () )
6869#if MIN_VERSION_ghc(9,13,0)
6970 , lookupFinderCache = \ im -> do
7071#else
7172 , lookupFinderCache = \ (GWIB im _) -> do
7273#endif
7374 if moduleUnit im `elem` hsc_all_home_unit_ids hscEnv'
74- then error ( " tried to lookup home module from FC" ++ showSDocUnsafe (ppr (im, hsc_all_home_unit_ids hscEnv')))
75+ then throwIO $ Exc. ErrorCall ( " lookupFinderCache: tried to lookup home module from FC: " ++ showSDocUnsafe (ppr (im, hsc_all_home_unit_ids hscEnv')))
7576 else lookupInstalledModuleEnv <$> readIORef mod_cache <*> pure im
76- , lookupFileCache = \ fp -> error ( " not used by HLS " ++ fp)
77+ , lookupFileCache = \ fp -> throwIO $ Exc. ErrorCall ( " lookupFileCache: Called without using setFileCacheHook for target: " ++ fp)
7778 }
7879 }
7980
0 commit comments