From 0b1405d0f7044a02bf26b1276c6ebb409d113521 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 29 Aug 2015 08:46:44 +0000 Subject: Improve exception messages when reading an HTTPResponse --- lib/httpserver/HTTPResponse.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/httpserver/HTTPResponse.cpp b/lib/httpserver/HTTPResponse.cpp index a7ef42ce..c56f286f 100644 --- a/lib/httpserver/HTTPResponse.cpp +++ b/lib/httpserver/HTTPResponse.cpp @@ -341,22 +341,22 @@ void HTTPResponse::Receive(IOStream& rStream, int Timeout) if(rGetLine.IsEOF()) { // Connection terminated unexpectedly - THROW_EXCEPTION(HTTPException, BadResponse) + THROW_EXCEPTION_MESSAGE(HTTPException, BadResponse, + "HTTP server closed the connection without sending a response"); } std::string statusLine; if(!rGetLine.GetLine(statusLine, false /* no preprocess */, Timeout)) { // Timeout - THROW_EXCEPTION(HTTPException, ResponseReadFailed) + THROW_EXCEPTION_MESSAGE(HTTPException, ResponseReadFailed, + "Failed to get a response from the HTTP server within the timeout"); } - if (statusLine.substr(0, 7) != "HTTP/1." || - statusLine[8] != ' ') + if (statusLine.substr(0, 7) != "HTTP/1." || statusLine[8] != ' ') { - // Status line terminated unexpectedly - BOX_ERROR("Bad response status line: " << statusLine); - THROW_EXCEPTION(HTTPException, BadResponse) + THROW_EXCEPTION_MESSAGE(HTTPException, BadResponse, + "HTTP server sent an invalid HTTP status line: " << statusLine); } if (statusLine[5] == '1' && statusLine[7] == '1') -- cgit v1.2.3