@@ -181,8 +181,8 @@ canonicalizeUri uri = filePathToUri <$> canonicalizePath (fromJust (uriToFilePat
181181diagnostic :: Session (NotificationMessage TextDocumentPublishDiagnostics )
182182diagnostic = LspTest. message STextDocumentPublishDiagnostics
183183
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
186186 let cm = SCustomMethod " test"
187187 waitId <- sendRequest cm (A. toJSON cmd)
188188 ResponseMessage {_result} <- skipManyTill anyMessage $ responseForId cm waitId
@@ -192,21 +192,29 @@ callTestPlugin cmd = do
192192 A. Success a -> a
193193 A. Error e -> error e
194194
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+
195203waitForAction :: String -> TextDocumentIdentifier -> Session WaitForIdeRuleResult
196204waitForAction key TextDocumentIdentifier {_uri} =
197205 callTestPlugin (WaitForIdeRule key _uri)
198206
199- getBuildKeysBuilt :: Session [T. Text ]
200- getBuildKeysBuilt = callTestPlugin GetBuildKeysBuilt
207+ getBuildKeysBuilt :: Session ( Either ResponseError [T. Text ])
208+ getBuildKeysBuilt = tryCallTestPlugin GetBuildKeysBuilt
201209
202- getBuildKeysVisited :: Session [T. Text ]
203- getBuildKeysVisited = callTestPlugin GetBuildKeysVisited
210+ getBuildKeysVisited :: Session ( Either ResponseError [T. Text ])
211+ getBuildKeysVisited = tryCallTestPlugin GetBuildKeysVisited
204212
205- getBuildKeysChanged :: Session [T. Text ]
206- getBuildKeysChanged = callTestPlugin GetBuildKeysChanged
213+ getBuildKeysChanged :: Session ( Either ResponseError [T. Text ])
214+ getBuildKeysChanged = tryCallTestPlugin GetBuildKeysChanged
207215
208- getBuildEdgesCount :: Session Int
209- getBuildEdgesCount = callTestPlugin GetBuildEdgesCount
216+ getBuildEdgesCount :: Session ( Either ResponseError Int )
217+ getBuildEdgesCount = tryCallTestPlugin GetBuildEdgesCount
210218
211219getInterfaceFilesDir :: TextDocumentIdentifier -> Session FilePath
212220getInterfaceFilesDir TextDocumentIdentifier {_uri} = callTestPlugin (GetInterfaceFilesDir _uri)
0 commit comments