aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpsys.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-10-02 12:00:00 +0200
committerGitHub <[email protected]>2023-10-02 12:00:00 +0200
commit0abf7994e8913c19360a0f0b8527495c0f99de87 (patch)
treea9a0338d69a95a6f20d9634a2a0e9f5b1595b639 /src/zenhttp/httpsys.cpp
parentLimit size of memory cache layer (#423) (diff)
downloadzen-0abf7994e8913c19360a0f0b8527495c0f99de87.tar.xz
zen-0abf7994e8913c19360a0f0b8527495c0f99de87.zip
Handle OOM and OOD more gracefully to not spam Sentry with error reports (#434)
- Improvement: Catch Out Of Memory and Out Of Disk exceptions and report back to reqeuster without reporting an error to Sentry - Improvement: If creating bucket fails when storing and item in the structured cache, log a warning and propagate error to requester without reporting an error to Sentry - Improvement: Make an explicit flush of the active block written to in blockstore flush - Improvement: Make sure cache and cas MakeIndexSnapshot does not throw exception on failure which would cause and abnormal termniation at exit
Diffstat (limited to 'src/zenhttp/httpsys.cpp')
-rw-r--r--src/zenhttp/httpsys.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/zenhttp/httpsys.cpp b/src/zenhttp/httpsys.cpp
index 8c1f68ee8..60358d0b0 100644
--- a/src/zenhttp/httpsys.cpp
+++ b/src/zenhttp/httpsys.cpp
@@ -1812,11 +1812,24 @@ InitialRequestHandler::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfBytesT
// Unable to route
return new HttpMessageResponseRequest(Transaction(), 404, "No suitable route found"sv);
}
+ catch (std::system_error& SystemError)
+ {
+ if (IsOOM(SystemError.code()) || IsOOD(SystemError.code()))
+ {
+ return new HttpMessageResponseRequest(Transaction(), (uint16_t)HttpResponseCode::InsufficientStorage, SystemError.what());
+ }
+
+ ZEN_ERROR("Caught system error exception while handling request: {}", SystemError.what());
+ return new HttpMessageResponseRequest(Transaction(), (uint16_t)HttpResponseCode::InternalServerError, SystemError.what());
+ }
+ catch (std::bad_alloc& BadAlloc)
+ {
+ return new HttpMessageResponseRequest(Transaction(), (uint16_t)HttpResponseCode::InsufficientStorage, BadAlloc.what());
+ }
catch (std::exception& ex)
{
ZEN_ERROR("Caught exception while handling request: '{}'", ex.what());
-
- return new HttpMessageResponseRequest(Transaction(), 500, ex.what());
+ return new HttpMessageResponseRequest(Transaction(), (uint16_t)HttpResponseCode::InternalServerError, ex.what());
}
}