1 module Language.Haskell.LSP.Test.Exceptions where
3 import Control.Exception
4 import Language.Haskell.LSP.Messages
6 data SessionException = TimeoutException
7 | UnexpectedMessageException String FromServerMessage
8 | ReplayOutOfOrderException FromServerMessage [FromServerMessage]
9 | UnexpectedDiagnosticsException
10 | IncorrectApplyEditRequestException String
12 instance Exception SessionException
14 instance Show SessionException where
15 show TimeoutException = "Timed out waiting to receive a message from the server."
16 show (UnexpectedMessageException expected lastMsg) =
17 "Received an unexpected message from the server:\n" ++
18 "Expected: " ++ expected ++ "\n" ++
19 "Last message accepted: " ++ show lastMsg
20 show (ReplayOutOfOrderException received expected) =
21 "Replay is out of order:\n" ++
22 "Received from server:" ++ show received ++ "\n" ++
23 "Expected one of: " ++ concatMap show expected
24 show UnexpectedDiagnosticsException = "Unexpectedly received diagnostics from the server."
25 show (IncorrectApplyEditRequestException msgStr) = "ApplyEditRequest didn't contain document, instead received:\n"
28 anySessionException :: SessionException -> Bool
29 anySessionException = const True