X-Git-Url: http://git.lukelau.me/?a=blobdiff_plain;f=src%2FLanguage%2FHaskell%2FLSP%2FTest%2FExceptions.hs;h=e9c65f9598711b89963884e5207488e471655548;hb=bd6901688e6c9d8332fea161260d32666885f9ed;hp=deea111f3e43006ce8084653b6e287b489950048;hpb=0f8b9d328f4d950ff0a2e1c3b5aed593b21c2d3a;p=lsp-test.git diff --git a/src/Language/Haskell/LSP/Test/Exceptions.hs b/src/Language/Haskell/LSP/Test/Exceptions.hs index deea111..e9c65f9 100644 --- a/src/Language/Haskell/LSP/Test/Exceptions.hs +++ b/src/Language/Haskell/LSP/Test/Exceptions.hs @@ -1,10 +1,24 @@ module Language.Haskell.LSP.Test.Exceptions where import Control.Exception +import Language.Haskell.LSP.Messages data SessionException = TimeoutException - deriving Show + | UnexpectedMessageException String FromServerMessage + | ReplayOutOfOrderException FromServerMessage [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 + show (ReplayOutOfOrderException received expected) = + "Replay is out of order:\n" ++ + "Received from server:" ++ show received ++ "\n" ++ + "Expected one of: " ++ concatMap show expected + anySessionException :: SessionException -> Bool anySessionException = const True \ No newline at end of file