[Libreoffice-commits] online.git: 2 commits - loolwsd/Exceptions.hpp loolwsd/LOOLWSD.cpp
Tor Lillqvist
tml at collabora.com
Tue Oct 18 05:40:28 UTC 2016
loolwsd/Exceptions.hpp | 6 ++++++
loolwsd/LOOLWSD.cpp | 14 +++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
New commits:
commit b02a917f0a6b7e6f12ea312a2624c8556b268a05
Author: Tor Lillqvist <tml at collabora.com>
Date: Tue Oct 18 08:32:18 2016 +0300
Introduce LoolException::toString() to avoid a few std::string casts
Also consistently cast the call of std::exception::what() and not a
string literal being conatenated with that.
diff --git a/loolwsd/Exceptions.hpp b/loolwsd/Exceptions.hpp
index b9839c8..de5fcaa 100644
--- a/loolwsd/Exceptions.hpp
+++ b/loolwsd/Exceptions.hpp
@@ -17,6 +17,12 @@
// Generic LOOL errors and base for others.
class LoolException : public std::runtime_error
{
+public:
+ std::string toString() const
+ {
+ return what();
+ }
+
protected:
using std::runtime_error::runtime_error;
};
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 507f6fe..90dba8e 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -507,7 +507,7 @@ private:
}
catch (const std::exception& ex)
{
- Log::error(std::string("Failed to get save-as url: ") + ex.what());
+ Log::error("Failed to get save-as url: " + std::string(ex.what()));
}
lock.lock();
@@ -1080,7 +1080,7 @@ public:
catch (const WebSocketErrorMessageException& exc)
{
// Internal error that should be passed on to the client.
- Log::error(std::string("ClientRequestHandler::handleClientRequest: WebSocketErrorMessageException: ") + exc.what());
+ Log::error("ClientRequestHandler::handleClientRequest: WebSocketErrorMessageException: " + exc.toString());
try
{
ws->sendFrame(exc.what(), std::strlen(exc.what()));
@@ -1089,7 +1089,7 @@ public:
}
catch (const std::exception& exc2)
{
- Log::error(std::string("ClientRequestHandler::handleClientRequest: exception while sending WS error message: ") + exc2.what());
+ Log::error("ClientRequestHandler::handleClientRequest: exception while sending WS error message: " + std::string(exc2.what()));
}
}
}
@@ -1108,17 +1108,17 @@ public:
}
catch (const UnauthorizedRequestException& exc)
{
- Log::error(std::string("ClientRequestHandler::handleClientRequest: UnauthorizedException: ") + exc.what());
+ Log::error("ClientRequestHandler::handleClientRequest: UnauthorizedException: " + exc.toString());
response.setStatusAndReason(HTTPResponse::HTTP_UNAUTHORIZED);
}
catch (const BadRequestException& exc)
{
- Log::error(std::string("ClientRequestHandler::handleClientRequest: BadRequestException: ") + exc.what());
+ Log::error("ClientRequestHandler::handleClientRequest: BadRequestException: " + exc.toString());
response.setStatusAndReason(HTTPResponse::HTTP_BAD_REQUEST);
}
catch (const std::exception& exc)
{
- Log::error(std::string("ClientRequestHandler::handleClientRequest: Exception: ") + exc.what());
+ Log::error("ClientRequestHandler::handleClientRequest: Exception: " + std::string(exc.what()));
response.setStatusAndReason(HTTPResponse::HTTP_SERVICE_UNAVAILABLE);
}
commit 72133868b58006db1fdd4fc09ee3e850494f83af
Author: Tor Lillqvist <tml at collabora.com>
Date: Tue Oct 18 08:22:46 2016 +0300
Use correct function name in some log messages
These Log::foo() calls are in ClientRequestHandler::handleClientRequest(),
not in ClientRequestHandler::handleRequest().
Actually I wonder why we show the name of the function in this handful of
places. We don't do it in general. Consistency, bah.
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 42c605f..507f6fe 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1080,7 +1080,7 @@ public:
catch (const WebSocketErrorMessageException& exc)
{
// Internal error that should be passed on to the client.
- Log::error(std::string("ClientRequestHandler::handleRequest: WebSocketErrorMessageException: ") + exc.what());
+ Log::error(std::string("ClientRequestHandler::handleClientRequest: WebSocketErrorMessageException: ") + exc.what());
try
{
ws->sendFrame(exc.what(), std::strlen(exc.what()));
@@ -1089,7 +1089,7 @@ public:
}
catch (const std::exception& exc2)
{
- Log::error(std::string("ClientRequestHandler::handleRequest: exception while sending WS error message: ") + exc2.what());
+ Log::error(std::string("ClientRequestHandler::handleClientRequest: exception while sending WS error message: ") + exc2.what());
}
}
}
@@ -1101,24 +1101,24 @@ public:
}
catch (const Exception& exc)
{
- Log::error() << "ClientRequestHandler::handleRequest: " << exc.displayText()
+ Log::error() << "ClientRequestHandler::handleClientRequest: " << exc.displayText()
<< (exc.nested() ? " (" + exc.nested()->displayText() + ")" : "")
<< Log::end;
response.setStatusAndReason(HTTPResponse::HTTP_SERVICE_UNAVAILABLE);
}
catch (const UnauthorizedRequestException& exc)
{
- Log::error(std::string("ClientRequestHandler::handleRequest: UnauthorizedException: ") + exc.what());
+ Log::error(std::string("ClientRequestHandler::handleClientRequest: UnauthorizedException: ") + exc.what());
response.setStatusAndReason(HTTPResponse::HTTP_UNAUTHORIZED);
}
catch (const BadRequestException& exc)
{
- Log::error(std::string("ClientRequestHandler::handleRequest: BadRequestException: ") + exc.what());
+ Log::error(std::string("ClientRequestHandler::handleClientRequest: BadRequestException: ") + exc.what());
response.setStatusAndReason(HTTPResponse::HTTP_BAD_REQUEST);
}
catch (const std::exception& exc)
{
- Log::error(std::string("ClientRequestHandler::handleRequest: Exception: ") + exc.what());
+ Log::error(std::string("ClientRequestHandler::handleClientRequest: Exception: ") + exc.what());
response.setStatusAndReason(HTTPResponse::HTTP_SERVICE_UNAVAILABLE);
}
More information about the Libreoffice-commits
mailing list