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