VAR.WebFormsCore: Wrap RouteRequest and Flush inside a try-catch to capture unhandled exceptions

This commit is contained in:
2021-07-01 02:46:31 +02:00
parent 75f8d9c7d7
commit 5a9ae6dc93

View File

@@ -33,16 +33,25 @@ namespace VAR.WebFormsCore.Code
try try
{ {
RouteRequest(httpContext); RouteRequest(httpContext);
await httpContext.Response.Body.FlushAsync();
} }
catch (Exception ex) catch (Exception ex)
{ {
if (IsIgnoreException(ex) == false) if (IsIgnoreException(ex) == false)
{ {
GlobalErrorHandler.HandleError(httpContext, ex); try
{
// TODO: Implement better error logging
Console.WriteLine("!!!!!!!!!!");
Console.Write("Message: {0}\nStacktrace: {1}\n", ex.Message, ex.StackTrace);
GlobalErrorHandler.HandleError(httpContext, ex);
await httpContext.Response.Body.FlushAsync();
}
catch (Exception) { /* Nom nom nom */}
} }
} }
await httpContext.Response.Body.FlushAsync();
} }
private static bool IsIgnoreException(Exception ex) private static bool IsIgnoreException(Exception ex)