From 96903b4d25140301b64f71163d2f5f490212666b Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Tue, 2 Oct 2018 12:29:14 -0700 Subject: [PATCH] Improve doc and examples related to error handling --- README.md | 10 ++++++---- examples/cmd_websocket_chat.cpp | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ccb07741..192f5667 100644 --- a/README.md +++ b/README.md @@ -138,10 +138,12 @@ webSocket.setOnMessageCallback( { if (messageType == ix::WebSocket_MessageType_Error) { - ss << "cmd_websocket_chat: Error ! " << error.reason << std::endl; - ss << "#retries: " << event.retries << std::endl; - ss << "Wait time(ms): " << event.waitTime << std::endl; - ss << "HTTP Status: " << event.httpStatus << std::endl; + std::stringstream ss; + ss << "Error: " << error.reason << std::endl; + ss << "#retries: " << event.retries << std::endl; + ss << "Wait time(ms): " << event.wait_time << std::endl; + ss << "HTTP Status: " << event.http_status << std::endl; + std::cout << ss.str() << std::endl; } } ); diff --git a/examples/cmd_websocket_chat.cpp b/examples/cmd_websocket_chat.cpp index 4289502c..098f4999 100644 --- a/examples/cmd_websocket_chat.cpp +++ b/examples/cmd_websocket_chat.cpp @@ -117,7 +117,10 @@ namespace } else if (messageType == ix::WebSocket_MessageType_Error) { - ss << "cmd_websocket_chat: Error ! " << error.reason; + ss << "Connection error: " << error.reason << std::endl; + ss << "#retries: " << error.retries << std::endl; + ss << "Wait time(ms): " << error.wait_time << std::endl; + ss << "HTTP Status: " << error.http_status << std::endl; log(ss.str()); } else