Update HttpServer.cs

Fixed an error where if an exception was hit that was other than an `AggregateException` would result in a generic 404, rather than a 500 with the exception details
This commit is contained in:
Kaveman
2024-08-16 00:46:56 -07:00
parent ff1b4bfd2c
commit 27fe310191

View File

@@ -129,9 +129,6 @@ namespace WebServer {
response = cache; response = cache;
else if (cache.UpdateMethod != null) else if (cache.UpdateMethod != null)
response = await cache.UpdateMethod(context, cache); response = await cache.UpdateMethod(context, cache);
else {
}
} }
// Create reponse timeout logic, this will return a string to the client but an exception on the server // Create reponse timeout logic, this will return a string to the client but an exception on the server
@@ -186,7 +183,7 @@ namespace WebServer {
bool fileExists = File.Exists(fullpath); bool fileExists = File.Exists(fullpath);
if (!fileExists) continue; if (!fileExists) continue;
cache = cache ?? new CachedResponse(this, null); cache ??= new CachedResponse(this, null);
cache.StatusCode = HttpStatusCode.OK; cache.StatusCode = HttpStatusCode.OK;
cache.ContentString = await razorEngine.CompileRenderAsync<object?>(razorPath, null); cache.ContentString = await razorEngine.CompileRenderAsync<object?>(razorPath, null);
cache.ContentType = "text/html"; cache.ContentType = "text/html";
@@ -212,7 +209,7 @@ namespace WebServer {
}; };
} }
catch (Exception ex) { catch (Exception ex) {
StatusPageModel statusModel = new StatusPageModel(HttpStatusCode.InternalServerError) { statusPageModel = new StatusPageModel(HttpStatusCode.InternalServerError) {
Exception = ex Exception = ex
}; };
} }