X-Git-Url: https://git.lukelau.me/?a=blobdiff_plain;f=src%2FLanguage%2FHaskell%2FLSP%2FTest%2FExceptions.hs;h=b28e256cc0857522c4558dd2d38e3823b6b3efbf;hb=84e2707604b3a64c00062104fa40e2ea76040155;hp=713b25f101a23429668a1f29207e8f2c4a63645e;hpb=4246f66333d522b30688f21a6b17bd2259451240;p=lsp-test.git diff --git a/src/Language/Haskell/LSP/Test/Exceptions.hs b/src/Language/Haskell/LSP/Test/Exceptions.hs index 713b25f..b28e256 100644 --- a/src/Language/Haskell/LSP/Test/Exceptions.hs +++ b/src/Language/Haskell/LSP/Test/Exceptions.hs @@ -1,7 +1,6 @@ module Language.Haskell.LSP.Test.Exceptions where import Control.Exception -import Language.Haskell.LSP.Messages import Language.Haskell.LSP.Types import Data.Aeson import Data.Aeson.Encode.Pretty @@ -17,8 +16,9 @@ data SessionException = Timeout (Maybe FromServerMessage) | ReplayOutOfOrder FromServerMessage [FromServerMessage] | UnexpectedDiagnostics | IncorrectApplyEditRequest String - | UnexpectedResponseError LspIdRsp ResponseError + | UnexpectedResponseError SomeLspId ResponseError | UnexpectedServerTermination + | IllegalInitSequenceMessage FromServerMessage deriving Eq instance Exception SessionException @@ -33,7 +33,7 @@ instance Show SessionException where show (UnexpectedMessage expected lastMsg) = "Received an unexpected message from the server:\n" ++ "Was parsing: " ++ expected ++ "\n" ++ - "Last message received:\n" ++ B.unpack (encodePretty lastMsg) + "But the last message received was:\n" ++ B.unpack (encodePretty lastMsg) show (ReplayOutOfOrder received expected) = let expected' = nub expected getJsonDiff = lines . B.unpack . encodePretty @@ -50,6 +50,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