From a2a70e833916ce6e2b7e2c52e4ea6df779e0730c Mon Sep 17 00:00:00 2001 From: GHXX Date: Sat, 13 Jan 2024 03:14:10 +0100 Subject: [PATCH] Catch exception on shutdown --- SimpleHttpServer/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/SimpleHttpServer/HttpServer.cs b/SimpleHttpServer/HttpServer.cs index 4c20c37..bff035f 100644 --- a/SimpleHttpServer/HttpServer.cs +++ b/SimpleHttpServer/HttpServer.cs @@ -46,6 +46,7 @@ public sealed class HttpServer { try { var ctx = await listener.GetContextAsync(); _ = ProcessRequestAsync(ctx); + } catch (HttpListenerException ex) when (ex.ErrorCode == 995) { //The I/O operation has been aborted because of either a thread exit or an application request } catch (Exception ex) { logger.Fatal($"Caught otherwise uncaught exception in GetContextLoop:\n{ex}"); }