Skip to content

Commit 5217a04

Browse files
pepeiborraisovector
authored andcommitted
log exceptions before killing the server (haskell#1651)
* log hiedb exceptions before killing the server * This is not the hiedb thread - fix message * Fix handler - either an error or success
1 parent 80662f2 commit 5217a04

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ghcide/src/Development/IDE/LSP/LanguageServer.hs

+6-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
141141
logInfo (ideLogger ide) $ T.pack $ "Registering ide configuration: " <> show initConfig
142142
registerIdeConfiguration (shakeExtras ide) initConfig
143143

144-
_ <- flip forkFinally (const exitClientMsg) $ runWithDb dbLoc $ \hiedb hieChan -> do
144+
let handleServerException (Left e) = do
145+
logError (ideLogger ide) $
146+
T.pack $ "Fatal error in server thread: " <> show e
147+
exitClientMsg
148+
handleServerException _ = pure ()
149+
_ <- flip forkFinally handleServerException $ runWithDb dbLoc $ \hiedb hieChan -> do
145150
putMVar dbMVar (hiedb,hieChan)
146151
forever $ do
147152
msg <- readChan clientMsgChan

0 commit comments

Comments
 (0)