diff options
| author | Zousar Shaker <[email protected]> | 2021-12-01 16:25:41 -0700 |
|---|---|---|
| committer | Zousar Shaker <[email protected]> | 2021-12-01 16:25:41 -0700 |
| commit | e9ba6682923b4831b26ac6c32ccce2e1527922ea (patch) | |
| tree | 2dee83198c309bad1a4561cc77448b44eba9cf62 /zenhttp/httpasio.cpp | |
| parent | Address review feedback/comments. (diff) | |
| download | zen-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.cpp | 12 |
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)) |