Skip to content

Commit

Permalink
Use errorHandles in cdrale intialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jneira committed Nov 25, 2019
1 parent 63ba2d4 commit 8f5558e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,18 @@ loadCradle iniDynFlags (NewCradle fp) def action = do
-- while 'f' is still valid.
liftIO (GHC.newHscEnv iniDynFlags) >>= GHC.setSession
liftIO $ setCurrentDirectory (BIOS.cradleRootDir cradle)
init_res <- gcatches (Right <$> init_session)
[ErrorHandler (\(ex :: GHC.GhcException)
-> return $ Left (GHC.showGhcException ex ""))]

let onGhcError = return . Left
let onSourceError = const . return $ Right ()
-- We continue setting the cradle in case the file has source errors
-- cause they will be reported to user by diagnostics
init_res <- gcatches
(Right <$> init_session)
(errorHandlers onGhcError onSourceError)

case init_res of
Left err -> do
logm $ "GhcException on cradle initialisation: " ++ show err
logm $ "Ghc error on cradle initialisation: " ++ show err
return $ IdeResultFail $ IdeError
{ ideCode = OtherError
, ideMessage = Text.pack $ show err
Expand Down

0 comments on commit 8f5558e

Please sign in to comment.