Skip to content

Commit 90a4b14

Browse files
committed
send message in server exception too
1 parent 83ae7af commit 90a4b14

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,23 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
142142
let handleServerException (Left e) = do
143143
logError logger $
144144
T.pack $ "Fatal error in server thread: " <> show e
145+
sendErrorMessage e
145146
exitClientMsg
146147
handleServerException _ = pure ()
147148

148-
uncaughtError (e :: SomeException) = do
149-
logError logger $ T.pack $
150-
"Unexpected exception on notification, please report!\n" ++
151-
"Exception: " ++ show e
149+
sendErrorMessage (e :: SomeException) = do
152150
LSP.runLspT env $ LSP.sendNotification SWindowShowMessage $
153151
ShowMessageParams MtError $ T.unlines
154-
[ "Unhandled error, please [report](" <> issueTrackerUrl <> "): "
152+
[ "Unhandled exception, please [report](" <> issueTrackerUrl <> "): "
155153
, T.pack(show e)
156154
]
155+
156+
exceptionInHandler e = do
157+
logError logger $ T.pack $
158+
"Unexpected exception, please report!\n" ++
159+
"Exception: " ++ show e
160+
sendErrorMessage e
161+
157162
logger = ideLogger ide
158163

159164
checkCancelled _id act k =
@@ -170,7 +175,7 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
170175
k $ ResponseError RequestCancelled "" Nothing
171176
Right res -> pure res
172177
) $ \(e :: SomeException) -> do
173-
uncaughtError e
178+
exceptionInHandler e
174179
k $ ResponseError InternalError (T.pack $ show e) Nothing
175180
_ <- flip forkFinally handleServerException $ runWithDb logger dbLoc $ \hiedb hieChan -> do
176181
putMVar dbMVar (hiedb,hieChan)
@@ -179,7 +184,7 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
179184
-- We dispatch notifications synchronously and requests asynchronously
180185
-- This is to ensure that all file edits and config changes are applied before a request is handled
181186
case msg of
182-
ReactorNotification act -> handle uncaughtError act
187+
ReactorNotification act -> handle exceptionInHandler act
183188
ReactorRequest _id act k -> void $ async $ checkCancelled _id act k
184189
pure $ Right (env,ide)
185190

0 commit comments

Comments
 (0)