X-Git-Url: http://git.lukelau.me/?a=blobdiff_plain;f=src%2FLanguage%2FHaskell%2FLSP%2FTest%2FExceptions.hs;h=88cf57d11ed6910391856ed85ffe9b244fcc5e26;hb=16501021ea92ae3c84dbfd99a3c2dd631685b49c;hp=e1e281fa435486e6bdd4bd4c9b9dfbcc2c1134d9;hpb=eab96ad6f11e0f76380d9cc600724f94c4523915;p=lsp-test.git diff --git a/src/Language/Haskell/LSP/Test/Exceptions.hs b/src/Language/Haskell/LSP/Test/Exceptions.hs index e1e281f..88cf57d 100644 --- a/src/Language/Haskell/LSP/Test/Exceptions.hs +++ b/src/Language/Haskell/LSP/Test/Exceptions.hs @@ -11,18 +11,25 @@ import Data.List import qualified Data.ByteString.Lazy.Char8 as B -- | An exception that can be thrown during a 'Haskell.LSP.Test.Session.Session' -data SessionException = Timeout +data SessionException = Timeout (Maybe FromServerMessage) + | NoContentLengthHeader | UnexpectedMessage String FromServerMessage | ReplayOutOfOrder FromServerMessage [FromServerMessage] | UnexpectedDiagnostics | IncorrectApplyEditRequest String | UnexpectedResponseError LspIdRsp ResponseError + | UnexpectedServerTermination deriving Eq instance Exception SessionException instance Show SessionException where - show Timeout = "Timed out waiting to receive a message from the server." + show (Timeout lastMsg) = + "Timed out waiting to receive a message from the server." ++ + case lastMsg of + Just msg -> "\nLast message received: " ++ show 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" ++ @@ -42,6 +49,7 @@ instance Show SessionException where ++ msgStr show (UnexpectedResponseError lid e) = "Received an exepected error in a response for id " ++ show lid ++ ":\n" ++ show e + show UnexpectedServerTermination = "Language server unexpectedly terminated" -- | A predicate that matches on any 'SessionException' anySessionException :: SessionException -> Bool