aboutsummaryrefslogtreecommitdiff
path: root/zenhttp/httpasio.cpp
diff options
context:
space:
mode:
authorZousar Shaker <[email protected]>2021-12-01 16:25:41 -0700
committerZousar Shaker <[email protected]>2021-12-01 16:25:41 -0700
commite9ba6682923b4831b26ac6c32ccce2e1527922ea (patch)
tree2dee83198c309bad1a4561cc77448b44eba9cf62 /zenhttp/httpasio.cpp
parentAddress review feedback/comments. (diff)
downloadzen-e9ba6682923b4831b26ac6c32ccce2e1527922ea.tar.xz
zen-e9ba6682923b4831b26ac6c32ccce2e1527922ea.zip
Wrap asio call to Service->HandleRequest in try/catch like http.sys.
Diffstat (limited to 'zenhttp/httpasio.cpp')
-rw-r--r--zenhttp/httpasio.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/zenhttp/httpasio.cpp b/zenhttp/httpasio.cpp
index 9a23a25ef..7ee7193d1 100644
--- a/zenhttp/httpasio.cpp
+++ b/zenhttp/httpasio.cpp
@@ -500,7 +500,17 @@ HttpServerConnection::HandleRequest()
if (!HandlePackageOffers(*Service, Request, m_PackageHandler))
{
- Service->HandleRequest(Request);
+ try
+ {
+ Service->HandleRequest(Request);
+ }
+ catch (std::exception& ex)
+ {
+ ZEN_ERROR("Caught exception while handling request: '{}'", ex.what());
+
+ Request.WriteResponse(HttpResponseCode::InternalServerError, HttpContentType::kText, ex.what());
+ }
+
}
if (std::unique_ptr<HttpResponse> Response = std::move(Request.m_Response))