Skip to content

Commit 9d875c2

Browse files
committed
send message in server exception too
1 parent e70fb03 commit 9d875c2

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
@@ -141,18 +141,23 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
141141
let handleServerException (Left e) = do
142142
logError logger $
143143
T.pack $ "Fatal error in server thread: " <> show e
144+
sendErrorMessage e
144145
exitClientMsg
145146
handleServerException _ = pure ()
146147

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

158163
checkCancelled _id act k =
@@ -169,7 +174,7 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
169174
k $ ResponseError RequestCancelled "" Nothing
170175
Right res -> pure res
171176
) $ \(e :: SomeException) -> do
172-
uncaughtError e
177+
exceptionInHandler e
173178
k $ ResponseError InternalError (T.pack $ show e) Nothing
174179
_ <- flip forkFinally handleServerException $ runWithDb logger dbLoc $ \hiedb hieChan -> do
175180
putMVar dbMVar (hiedb,hieChan)
@@ -178,7 +183,7 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
178183
-- We dispatch notifications synchronously and requests asynchronously
179184
-- This is to ensure that all file edits and config changes are applied before a request is handled
180185
case msg of
181-
ReactorNotification act -> handle uncaughtError act
186+
ReactorNotification act -> handle exceptionInHandler act
182187
ReactorRequest _id act k -> void $ async $ checkCancelled _id act k
183188
pure $ Right (env,ide)
184189

0 commit comments

Comments
 (0)