Pretty print last received messages
authorLuke Lau <luke_lau@icloud.com>
Tue, 26 Nov 2019 19:08:08 +0000 (19:08 +0000)
committerLuke Lau <luke_lau@icloud.com>
Tue, 26 Nov 2019 19:08:08 +0000 (19:08 +0000)
src/Language/Haskell/LSP/Test/Exceptions.hs

index 88cf57d11ed6910391856ed85ffe9b244fcc5e26..713b25f101a23429668a1f29207e8f2c4a63645e 100644 (file)
@@ -27,13 +27,13 @@ instance Show SessionException where
   show (Timeout lastMsg) =
     "Timed out waiting to receive a message from the server." ++
     case lastMsg of
-      Just msg -> "\nLast message received: " ++ show msg
+      Just msg -> "\nLast message received:\n" ++ B.unpack (encodePretty msg)
       Nothing -> mempty
   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" ++
-    "Last message received: " ++ show lastMsg
+    "Last message received:\n" ++ B.unpack (encodePretty lastMsg)
   show (ReplayOutOfOrder received expected) =
     let expected' = nub expected
         getJsonDiff = lines . B.unpack . encodePretty