Add new NoContentLengthHeader SessionException to replace raw error
[lsp-test.git] / src / Language / Haskell / LSP / Test / Exceptions.hs
index e1e281fa435486e6bdd4bd4c9b9dfbcc2c1134d9..dd31ea3cc155d879ba5366966b04e9b4ca5a4808 100644 (file)
@@ -12,17 +12,20 @@ import qualified Data.ByteString.Lazy.Char8 as B
 
 -- | An exception that can be thrown during a 'Haskell.LSP.Test.Session.Session'
 data SessionException = Timeout
+                      | 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 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 +45,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