Skip to content

Commit

Permalink
log exceptions before killing the server (haskell#1651)
Browse files Browse the repository at this point in the history
* log hiedb exceptions before killing the server

* This is not the hiedb thread - fix message

* Fix handler - either an error or success
  • Loading branch information
pepeiborra authored and berberman committed Apr 4, 2021
1 parent d84b6f0 commit 339819c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ghcide/src/Development/IDE/LSP/LanguageServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
logInfo (ideLogger ide) $ T.pack $ "Registering ide configuration: " <> show initConfig
registerIdeConfiguration (shakeExtras ide) initConfig

_ <- flip forkFinally (const exitClientMsg) $ runWithDb dbLoc $ \hiedb hieChan -> do
let handleServerException (Left e) = do
logError (ideLogger ide) $
T.pack $ "Fatal error in server thread: " <> show e
exitClientMsg
handleServerException _ = pure ()
_ <- flip forkFinally handleServerException $ runWithDb dbLoc $ \hiedb hieChan -> do
putMVar dbMVar (hiedb,hieChan)
forever $ do
msg <- readChan clientMsgChan
Expand Down

0 comments on commit 339819c

Please sign in to comment.