Handle receiving messages in between the initialize sequence
[lsp-test.git] / src / Language / Haskell / LSP / Test / Exceptions.hs
index 713b25f101a23429668a1f29207e8f2c4a63645e..afb48dfd4ff883962c804549f969bf71fc92a8fe 100644 (file)
@@ -19,6 +19,7 @@ data SessionException = Timeout (Maybe FromServerMessage)
                       | IncorrectApplyEditRequest String
                       | UnexpectedResponseError LspIdRsp ResponseError
                       | UnexpectedServerTermination
+                      | IllegalInitSequenceMessage FromServerMessage
   deriving Eq
 
 instance Exception SessionException
@@ -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