From 88b71f29d9ec2818efb3ef68cb252a0729c39557 Mon Sep 17 00:00:00 2001 From: Anna Date: Sat, 23 Mar 2024 13:17:51 -0400 Subject: [PATCH] chore: ignore more unactionable errors --- Plugin.cs | 26 +++++++++++++++++++++++++- Server.cs | 9 ++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Plugin.cs b/Plugin.cs index 803d51f..3e52614 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -347,6 +347,17 @@ private Configuration.SpeedLimit CalculateLimit() { private class ExceptionFilter : IExceptionFilter { private static readonly HashSet IgnoredHResults = [ + // hresult list + // https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/705fb797-2175-4a90-b5a3-3918024b10b8 + + // win32 error list (hresult 0x8007xxxx) + // https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d + // different win32 error list (primarily decimal) + // https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- + + // 0x80131620 is generic IOException (COR_E_IO) + + // ERROR_HANDLE_DISK_FULL unchecked((int) 0x80070027), // ERROR_DISK_FULL unchecked((int) 0x80070070), @@ -364,11 +375,24 @@ private class ExceptionFilter : IExceptionFilter { // SEC_E_UNSUPPORTED_FUNCTION // this is for the tls errors on wine unchecked((int) 0x80090302), + + // can't find this in the reference, but it's "The WOF driver + // "encountered a corruption in the compressed file's Resource + // Table." + unchecked((int) 0x80071160), + + // can't find this in the reference, but it's "A device which does + // not exist was specified." + unchecked((int) 0x800701b1), ]; #pragma warning disable SYSLIB1045 private static readonly List IgnoredMessages = [ new Regex(@"^No such host is known\.", RegexOptions.Compiled), + new Regex(@"An established connection was aborted by the software in your host machine\.", RegexOptions.Compiled), + new Regex(@"\(ResponseEnded\)", RegexOptions.Compiled), + new Regex(@"at least \d+ additional bytes expected", RegexOptions.Compiled), + new Regex(@"Unable to read data from the transport connection", RegexOptions.Compiled), ]; #pragma warning restore SYSLIB1045 @@ -397,7 +421,7 @@ public bool Filter(Exception ex) { } // ignore specific io errors - if (ex.GetHResults().Any(hResult => IgnoredHResults.Contains(hResult))) { + if (ex.GetHResults().Any(IgnoredHResults.Contains)) { return true; } diff --git a/Server.cs b/Server.cs index 81a6ec2..bed7425 100644 --- a/Server.cs +++ b/Server.cs @@ -111,7 +111,14 @@ internal void StartServer() { } private void HandleConnection() { - var ctx = this.Listener.GetContext(); + HttpListenerContext ctx; + try { + ctx = this.Listener.GetContext(); + } catch (HttpListenerException ex) { + Plugin.Log.Warning(ex, "Could not get request context"); + return; + } + var req = ctx.Request; var resp = ctx.Response; var url = req.Url?.AbsolutePath ?? "/";