Add unexpected message exception
[opengl.git] / src / Language / Haskell / LSP / Test / Exceptions.hs
index deea111f3e43006ce8084653b6e287b489950048..a25c802d5bcfd3750f03f2d46c8bad5412aea353 100644 (file)
@@ -1,10 +1,19 @@
 module Language.Haskell.LSP.Test.Exceptions where
 
 import Control.Exception
+import Language.Haskell.LSP.Messages
 
 data SessionException = TimeoutException
-  deriving Show
+                      | UnexpectedMessageException String FromServerMessage
+
 instance Exception SessionException
 
+instance Show SessionException where
+  show TimeoutException = "Timed out waiting to receive a message from the server."
+  show (UnexpectedMessageException expected lastMsg) =
+    "Received an unexpected message from the server:\n" ++
+    "Expected: " ++ expected ++ "\n" ++
+    "Last message accepted: " ++ show lastMsg
+
 anySessionException :: SessionException -> Bool
 anySessionException = const True
\ No newline at end of file