diff options
| author | Zeyla Hellyer <[email protected]> | 2018-04-25 21:37:17 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2018-04-25 21:37:17 -0700 |
| commit | 7b6b6016078c3492d2873d3eed0ddb39323079ab (patch) | |
| tree | f5f417a4eaa4307e8040bdf80aca7c3aebfdcbe9 /src | |
| parent | Remove empty whitespace at ends of lines (diff) | |
| download | serenity-7b6b6016078c3492d2873d3eed0ddb39323079ab.tar.xz serenity-7b6b6016078c3492d2873d3eed0ddb39323079ab.zip | |
Log more information about failed deserializations
Log more information when messages over the websocket fail to
deserialize properly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/internal/ws_impl.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/internal/ws_impl.rs b/src/internal/ws_impl.rs index 8c10264..5d8969b 100644 --- a/src/internal/ws_impl.rs +++ b/src/internal/ws_impl.rs @@ -20,11 +20,25 @@ impl ReceiverExt for WsClient<TlsStream<TcpStream>> { fn recv_json(&mut self) -> Result<Option<Value>> { Ok(match self.recv_message()? { OwnedMessage::Binary(bytes) => { - serde_json::from_reader(ZlibDecoder::new(&bytes[..])).map(Some)? + serde_json::from_reader(ZlibDecoder::new(&bytes[..])) + .map(Some) + .map_err(|why| { + warn!("Err deserializing bytes: {:?}; bytes: {:?}", why, bytes); + + why + })? }, OwnedMessage::Close(data) => return Err(Error::Gateway(GatewayError::Closed(data))), OwnedMessage::Text(payload) => { - serde_json::from_str(&payload).map(Some)? + serde_json::from_str(&payload).map(Some).map_err(|why| { + warn!( + "Err deserializing text: {:?}; text: {}", + why, + payload, + ); + + why + })? }, OwnedMessage::Ping(x) => { self.send_message(&OwnedMessage::Pong(x)) |