@@ -181,32 +181,40 @@ canonicalizeUri uri = filePathToUri <$> canonicalizePath (fromJust (uriToFilePat
181
181
diagnostic :: Session (NotificationMessage TextDocumentPublishDiagnostics )
182
182
diagnostic = LspTest. message STextDocumentPublishDiagnostics
183
183
184
- callTestPlugin :: (A. FromJSON b ) => TestRequest -> Session b
185
- callTestPlugin cmd = do
184
+ tryCallTestPlugin :: (A. FromJSON b ) => TestRequest -> Session ( Either ResponseError b )
185
+ tryCallTestPlugin cmd = do
186
186
let cm = SCustomMethod " test"
187
187
waitId <- sendRequest cm (A. toJSON cmd)
188
188
ResponseMessage {_result} <- skipManyTill anyMessage $ responseForId cm waitId
189
189
return $ case _result of
190
- Left ( ResponseError t err _) -> error $ show t <> " : " <> T. unpack err
190
+ Left e -> Left e
191
191
Right json -> case A. fromJSON json of
192
- A. Success a -> a
192
+ A. Success a -> Right a
193
193
A. Error e -> error e
194
194
195
+ callTestPlugin :: (A. FromJSON b ) => TestRequest -> Session b
196
+ callTestPlugin cmd = do
197
+ res <- tryCallTestPlugin cmd
198
+ case res of
199
+ Left (ResponseError t err _) -> error $ show t <> " : " <> T. unpack err
200
+ Right a -> pure a
201
+
202
+
195
203
waitForAction :: String -> TextDocumentIdentifier -> Session WaitForIdeRuleResult
196
204
waitForAction key TextDocumentIdentifier {_uri} =
197
205
callTestPlugin (WaitForIdeRule key _uri)
198
206
199
- getBuildKeysBuilt :: Session [T. Text ]
200
- getBuildKeysBuilt = callTestPlugin GetBuildKeysBuilt
207
+ getBuildKeysBuilt :: Session ( Either ResponseError [T. Text ])
208
+ getBuildKeysBuilt = tryCallTestPlugin GetBuildKeysBuilt
201
209
202
- getBuildKeysVisited :: Session [T. Text ]
203
- getBuildKeysVisited = callTestPlugin GetBuildKeysVisited
210
+ getBuildKeysVisited :: Session ( Either ResponseError [T. Text ])
211
+ getBuildKeysVisited = tryCallTestPlugin GetBuildKeysVisited
204
212
205
- getBuildKeysChanged :: Session [T. Text ]
206
- getBuildKeysChanged = callTestPlugin GetBuildKeysChanged
213
+ getBuildKeysChanged :: Session ( Either ResponseError [T. Text ])
214
+ getBuildKeysChanged = tryCallTestPlugin GetBuildKeysChanged
207
215
208
- getBuildEdgesCount :: Session Int
209
- getBuildEdgesCount = callTestPlugin GetBuildEdgesCount
216
+ getBuildEdgesCount :: Session ( Either ResponseError Int )
217
+ getBuildEdgesCount = tryCallTestPlugin GetBuildEdgesCount
210
218
211
219
getInterfaceFilesDir :: TextDocumentIdentifier -> Session FilePath
212
220
getInterfaceFilesDir TextDocumentIdentifier {_uri} = callTestPlugin (GetInterfaceFilesDir _uri)
0 commit comments