From e3f8671dd6e1c2d9cf6b9f5c9acb2fa6ac6b6920 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 22 Aug 2013 23:11:07 +0000 Subject: [PATCH] dbms: fixed error with OLAPHTTPHandler [#CONV-6757]. --- dbms/src/Server/OLAPHTTPHandler.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/dbms/src/Server/OLAPHTTPHandler.cpp b/dbms/src/Server/OLAPHTTPHandler.cpp index b2ecdbc617f..44f8e7e6ef8 100644 --- a/dbms/src/Server/OLAPHTTPHandler.cpp +++ b/dbms/src/Server/OLAPHTTPHandler.cpp @@ -102,42 +102,40 @@ namespace DB catch (DB::Exception & e) { response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); - std::ostream & ostr = response.send(); std::stringstream s; s << "Code: " << e.code() - << ", e.displayText() = " << e.displayText() << ", e.what() = " << e.what(); - ostr << s.str() << std::endl; + << ", e.displayText() = " << e.displayText() << ", e.what() = " << e.what(); + if (!response.sent()) + response.send() << s.str() << std::endl; LOG_ERROR(log, s.str()); } catch (Poco::Exception & e) { response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); - std::ostream & ostr = response.send(); std::stringstream s; s << "Code: " << ErrorCodes::POCO_EXCEPTION << ", e.code() = " << e.code() - << ", e.displayText() = " << e.displayText() << ", e.what() = " << e.what(); - ostr << s.str() << std::endl; + << ", e.displayText() = " << e.displayText() << ", e.what() = " << e.what(); + if (!response.sent()) + response.send() << s.str() << std::endl; LOG_ERROR(log, s.str()); } catch (std::exception & e) { response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); - std::ostream & ostr = response.send(); std::stringstream s; s << "Code: " << ErrorCodes::STD_EXCEPTION << ". " << e.what(); - ostr << s.str() << std::endl; + if (!response.sent()) + response.send() << s.str() << std::endl; LOG_ERROR(log, s.str()); } catch (...) { response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); - std::ostream & ostr = response.send(); std::stringstream s; s << "Code: " << ErrorCodes::UNKNOWN_EXCEPTION << ". Unknown exception."; - ostr << s.str() << std::endl; + if (!response.sent()) + response.send() << s.str() << std::endl; LOG_ERROR(log, s.str()); } } - - }