X-Git-Url: https://git.lukelau.me/?a=blobdiff_plain;f=src%2FLanguage%2FHaskell%2FLSP%2FTest%2FExceptions.hs;h=afb48dfd4ff883962c804549f969bf71fc92a8fe;hb=80a27eb1c9cb59c25bdf8c80926b897bc48f3672;hp=88cf57d11ed6910391856ed85ffe9b244fcc5e26;hpb=16501021ea92ae3c84dbfd99a3c2dd631685b49c;p=lsp-test.git diff --git a/src/Language/Haskell/LSP/Test/Exceptions.hs b/src/Language/Haskell/LSP/Test/Exceptions.hs index 88cf57d..afb48df 100644 --- a/src/Language/Haskell/LSP/Test/Exceptions.hs +++ b/src/Language/Haskell/LSP/Test/Exceptions.hs @@ -19,6 +19,7 @@ data SessionException = Timeout (Maybe FromServerMessage) | IncorrectApplyEditRequest String | UnexpectedResponseError LspIdRsp ResponseError | UnexpectedServerTermination + | IllegalInitSequenceMessage FromServerMessage deriving Eq instance Exception SessionException @@ -27,13 +28,13 @@ instance Show SessionException where show (Timeout lastMsg) = "Timed out waiting to receive a message from the server." ++ case lastMsg of - Just msg -> "\nLast message received: " ++ show msg + Just msg -> "\nLast message received:\n" ++ B.unpack (encodePretty msg) Nothing -> mempty show NoContentLengthHeader = "Couldn't read Content-Length header from the server." show (UnexpectedMessage expected lastMsg) = "Received an unexpected message from the server:\n" ++ "Was parsing: " ++ expected ++ "\n" ++ - "Last message received: " ++ show lastMsg + "Last message received:\n" ++ B.unpack (encodePretty lastMsg) show (ReplayOutOfOrder received expected) = let expected' = nub expected getJsonDiff = lines . B.unpack . encodePretty @@ -50,6 +51,9 @@ instance Show SessionException where show (UnexpectedResponseError lid e) = "Received an exepected error in a response for id " ++ show lid ++ ":\n" ++ show e show UnexpectedServerTermination = "Language server unexpectedly terminated" + show (IllegalInitSequenceMessage msg) = + "Received an illegal message between the initialize request and response:\n" + ++ B.unpack (encodePretty msg) -- | A predicate that matches on any 'SessionException' anySessionException :: SessionException -> Bool