@@ -141,18 +141,23 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
141
141
let handleServerException (Left e) = do
142
142
logError logger $
143
143
T. pack $ " Fatal error in server thread: " <> show e
144
+ sendErrorMessage e
144
145
exitClientMsg
145
146
handleServerException _ = pure ()
146
147
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
151
149
LSP. runLspT env $ LSP. sendNotification SWindowShowMessage $
152
150
ShowMessageParams MtError $ T. unlines
153
- [ " Unhandled error , please [report](" <> issueTrackerUrl <> " ): "
151
+ [ " Unhandled exception , please [report](" <> issueTrackerUrl <> " ): "
154
152
, T. pack(show e)
155
153
]
154
+
155
+ exceptionInHandler e = do
156
+ logError logger $ T. pack $
157
+ " Unexpected exception, please report!\n " ++
158
+ " Exception: " ++ show e
159
+ sendErrorMessage e
160
+
156
161
logger = ideLogger ide
157
162
158
163
checkCancelled _id act k =
@@ -169,7 +174,7 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
169
174
k $ ResponseError RequestCancelled " " Nothing
170
175
Right res -> pure res
171
176
) $ \ (e :: SomeException ) -> do
172
- uncaughtError e
177
+ exceptionInHandler e
173
178
k $ ResponseError InternalError (T. pack $ show e) Nothing
174
179
_ <- flip forkFinally handleServerException $ runWithDb logger dbLoc $ \ hiedb hieChan -> do
175
180
putMVar dbMVar (hiedb,hieChan)
@@ -178,7 +183,7 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
178
183
-- We dispatch notifications synchronously and requests asynchronously
179
184
-- This is to ensure that all file edits and config changes are applied before a request is handled
180
185
case msg of
181
- ReactorNotification act -> handle uncaughtError act
186
+ ReactorNotification act -> handle exceptionInHandler act
182
187
ReactorRequest _id act k -> void $ async $ checkCancelled _id act k
183
188
pure $ Right (env,ide)
184
189
0 commit comments